Module: Chef::Deprecation::Mixin::Template

Included in:
Provider::Template
Defined in:
lib/chef/deprecation/mixin/template.rb

Overview

Deprecation::Provider::Mixin::Template

This module contains the deprecated functions of Chef::Mixin::Template. These functions are refactored to different components. They are frozen and will be removed in Chef 13.

Instance Method Summary collapse

Instance Method Details

#render_template(template, context) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/chef/deprecation/mixin/template.rb', line 32

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
  Tempfile.open("chef-rendered-template") do |tempfile|
    tempfile.print(output)
    tempfile.close
    yield tempfile
  end
end