Class: Charmkit::Helpers::TemplateRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/charmkit/helpers/template.rb

Overview

Helper for rendering file and inline templates

Class Method Summary collapse

Class Method Details

.empty_bindingObject



7
8
9
# File 'lib/charmkit/helpers/template.rb', line 7

def self.empty_binding
  binding
end

.render(template_content, locals = {}) ⇒ Object



11
12
13
14
15
# File 'lib/charmkit/helpers/template.rb', line 11

def self.render(template_content, locals = {})
  b = empty_binding
  locals.each { |k, v| b.local_variable_set(k, v) }
  ERB.new(template_content).result(b)
end