Class: H2o::Tags::Extends

Inherits:
Tag show all
Defined in:
lib/h2o/tags/block.rb

Constant Summary collapse

Syntax =
/\"(.*?)\"|\'(.*?)\'/

Instance Method Summary collapse

Constructor Details

#initialize(parser, argstring) ⇒ Extends

Returns a new instance of Extends.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/h2o/tags/block.rb', line 37

def initialize parser, argstring
  unless parser.first? 
    raise SyntaxError, "extend tag needs to be at the beginning of the document"
  end
  # parser the entire subtemplate
  parser.parse()

  # load the parent template into nodelist
  @nodelist = Template.load(argstring[1...-1], parser.env)
  
  blocks = @nodelist.parser.storage[:blocks] || {}
  
  (parser.storage[:blocks] || []).each do |name, block|
    if blocks.include? name
      blocks[name].add_layer(block)
      block.parent =  blocks[name]
    end
  end
end

Instance Method Details

#render(context, stream) ⇒ Object



57
58
59
# File 'lib/h2o/tags/block.rb', line 57

def render context, stream
 @nodelist.render(context, stream)
end