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 post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to
puppet-users-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---