Class: Kokonfig::Template

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(templateString) ⇒ Template

Returns a new instance of Template.



6
7
8
# File 'lib/kokonfig/template.rb', line 6

def initialize(templateString)
  @template = templateString
end

Class Method Details

.from_file(path) ⇒ Object



10
11
12
13
# File 'lib/kokonfig/template.rb', line 10

def self.from_file(path)
  template = File.read(path)
  Kokonfig::Template.new(template)
end

Instance Method Details

#apply(data) ⇒ Object



15
16
17
18
# File 'lib/kokonfig/template.rb', line 15

def apply(data)
  object = Kokonfig::Objectifier.objectify(data)
  ERB.new(@template, nil, '-').result(object.instance_eval { binding })
end