Module: Chef::Mixin::Template
- Included in:
- Provider::Template
- Defined in:
- lib/chef/mixin/template.rb
Defined Under Namespace
Modules: ChefContext 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.
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/chef/mixin/template.rb', line 38 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 |