<%= 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