Module: Chef::Mixin::Template
- Included in:
- Provider::Template
- Defined in:
- lib/chef/mixin/template.rb
Defined Under Namespace
Classes: TemplateError
Instance Method Summary collapse
-
#render_template(template, context) ⇒ Object
Render a template with Erubis.
Instance Method Details
#render_template(template, context) ⇒ Object
Render a template with Erubis. Takes a template as a string, and a context hash.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/chef/mixin/template.rb', line 28 def render_template(template, context) begin eruby = Erubis::Eruby.new(template) output = eruby.evaluate(context) rescue Object => e raise TemplateError.new(e, template, context) end final_tempfile = Tempfile.new("chef-rendered-template") final_tempfile.print(output) final_tempfile.close final_tempfile end |