Class: LiquidPlugin

Inherits:
Henshin::LayoutParser show all
Defined in:
lib/henshin/plugins/liquid.rb

Instance Attribute Summary collapse

Attributes inherited from Henshin::StandardPlugin

#config

Instance Method Summary collapse

Constructor Details

#initializeLiquidPlugin

Returns a new instance of LiquidPlugin.



8
9
10
11
# File 'lib/henshin/plugins/liquid.rb', line 8

def initialize
  @extensions = {:input => [],
                 :output => ''}
end

Instance Attribute Details

#extensionsObject

Returns the value of attribute extensions.



6
7
8
# File 'lib/henshin/plugins/liquid.rb', line 6

def extensions
  @extensions
end

Instance Method Details

#generate(layout, data) ⇒ Object



13
14
15
16
# File 'lib/henshin/plugins/liquid.rb', line 13

def generate( layout, data )
  t = Liquid::Template.parse( read(layout) )
  t.render(data)
end

#read(file) ⇒ Object

returns the layout as a string



19
20
21
22
23
24
25
26
# File 'lib/henshin/plugins/liquid.rb', line 19

def read( file )
  f = File.open(file, "r")
  r = ""
  f.each do |l|
    r << l
  end
  r
end