Class: Linecook::Template

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Template

Returns a new instance of Template.



8
9
10
11
# File 'lib/linecook/template.rb', line 8

def initialize(filename)
  @erb = ERB.new File.read(filename)
  @erb.filename = filename
end

Instance Attribute Details

#erbObject (readonly)

Returns the value of attribute erb.



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

def erb
  @erb
end

Instance Method Details

#build(locals = {}) ⇒ Object



13
14
15
# File 'lib/linecook/template.rb', line 13

def build(locals={})
  erb.result OpenStruct.new(locals).instance_eval('binding')
end