Class: Burr::BlockTag

Inherits:
Liquid::Block
  • Object
show all
Defined in:
lib/burr/liquid_ext/block.rb

Constant Summary collapse

Syntax =
/(\w)+/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, tokens) ⇒ BlockTag

Returns a new instance of BlockTag.



20
21
22
23
24
25
26
27
28
# File 'lib/burr/liquid_ext/block.rb', line 20

def initialize(tag_name, markup, tokens)
  if markup =~ Syntax
    @name = $1
  else
    raise Liquid::SyntaxError.new("Syntax Error in 'block' - Valid syntax: block [name]")
  end

  super if tokens
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



18
19
20
# File 'lib/burr/liquid_ext/block.rb', line 18

def name
  @name
end

#parentObject

Returns the value of attribute parent.



17
18
19
# File 'lib/burr/liquid_ext/block.rb', line 17

def parent
  @parent
end

Instance Method Details

#add_parent(nodelist) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/burr/liquid_ext/block.rb', line 38

def add_parent(nodelist)
  if parent
    parent.add_parent(nodelist)
  else
    self.parent = BlockTag.new(@tag_name, @name, nil)
    parent.nodelist = nodelist
  end
end

#call_super(context) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/burr/liquid_ext/block.rb', line 47

def call_super(context)
  if parent
    parent.render(context)
  else
    ''
  end
end

#render(context) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/burr/liquid_ext/block.rb', line 30

def render(context)
  context.stack do
    context['block'] = BlockDrop.new(self)

    render_all(@nodelist, context)
  end
end