Class: Charmkit::Helpers::TemplateRenderer

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

Overview

Processes templates

template ‘my-template.erb’ ‘/etc/config/me.conf’, service_name: “nginx”

Class Method Summary collapse

Class Method Details

.empty_bindingObject



9
10
11
# File 'lib/charmkit/helpers/template.rb', line 9

def self.empty_binding
  binding
end

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



13
14
15
16
17
# File 'lib/charmkit/helpers/template.rb', line 13

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