Class: Bosh::Template::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/template/renderer.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Renderer

Returns a new instance of Renderer.



8
9
10
# File 'lib/bosh/template/renderer.rb', line 8

def initialize(options={})
  @context = options.fetch(:context)
end

Instance Method Details

#render(template_name) ⇒ Object



12
13
14
15
16
17
# File 'lib/bosh/template/renderer.rb', line 12

def render(template_name)
  spec = JSON.parse(@context)
  evaluation_context = EvaluationContext.new(spec, nil)
  template = ERB.new(File.read(template_name), safe_level = nil, trim_mode = "-")
  template.result(evaluation_context.get_binding)
end