http://stackoverflow.com/a/20856330/1242724
m.
On Tuesday, June 24, 2008 2:34:22 PM UTC+2, Thomas Bellman wrote:
>
> I have a few ERB templates that have some common parts, and I
> want to break out those parts into a separate file that I can
> just "include" in the main templates. If this included file is
> plain text, I can do
>
> <%= File.read("common.txt") %>
>
> This works as expected. However, I want to be able to use ERB
> templating inside that common file also, and now I'm having
> problems. After reading the documentation for ERB (starting at
> http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/index.html), and
> looking at the code in Puppet that invokes ERB, I came to the
> following:
>
> <%= ERB.new(File.read("common.erb"), 0, "-").result(binding) %>
>
> This only works partly. It correctly reads the common.erb file
> and expands the ERB code in it. Problem is, anything in my main
> templates before calling ERB.new(...) is discarded. I.e, if I
> have
>
> foo
> <%= ERB.new(File.read("common.erb"), 0, "-").result(binding) %>
> bar
>
> in my template, then the line "foo" just disappears. That's not
> quite what I wanted...
>
> What am I doing wrong, and how should I have done this?
>
>
> /Thomas Bellman
>
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/78ce536a-69b0-4682-b34c-0fe16e97a638%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.