Class: Itamae::Resource::Template::RenderContext
- Inherits:
-
Object
- Object
- Itamae::Resource::Template::RenderContext
- Defined in:
- lib/itamae/resource/template.rb
Instance Method Summary collapse
-
#initialize(resource) ⇒ RenderContext
constructor
A new instance of RenderContext.
- #node ⇒ Object
- #render(template) ⇒ Object
- #render_file(src) ⇒ Object
Constructor Details
#initialize(resource) ⇒ RenderContext
Returns a new instance of RenderContext.
19 20 21 22 23 24 25 |
# File 'lib/itamae/resource/template.rb', line 19 def initialize(resource) @resource = resource @resource.attributes.variables.each_pair do |key, value| instance_variable_set("@#{key}".to_sym, value) end end |
Instance Method Details
#node ⇒ Object
35 36 37 |
# File 'lib/itamae/resource/template.rb', line 35 def node @resource.recipe.runner.node end |
#render(template) ⇒ Object
27 28 29 |
# File 'lib/itamae/resource/template.rb', line 27 def render(template) ERB.new(template, nil, '-').result(binding) end |
#render_file(src) ⇒ Object
31 32 33 |
# File 'lib/itamae/resource/template.rb', line 31 def render_file(src) render(::File.read(src)) end |