Class: Swineherd::Template

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_template, attributes) ⇒ Template

Returns a new instance of Template.



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

def initialize source_template, attributes
  @source_template = source_template
  @attributes      = attributes
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

#source_templateObject

Returns the value of attribute source_template.



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

def source_template
  @source_template
end

Instance Method Details

#compile!Object



17
18
19
20
21
# File 'lib/swineherd/template.rb', line 17

def compile!
  dest << Erubis::Eruby.new(source).result(attributes)
  dest << "\n"
  dest
end

#substitute!Object



23
24
25
26
27
# File 'lib/swineherd/template.rb', line 23

def substitute!
  compile!
  dest.read
  dest.path
end