Class: LiquidBlocks::Block
- Inherits:
-
Liquid::Block
- Object
- Liquid::Block
- LiquidBlocks::Block
- Defined in:
- lib/liquid_blocks/block.rb
Constant Summary collapse
- SYNTAX =
/([\w!]+)/
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #add_parent(nodelist) ⇒ Object
- #blank? ⇒ Boolean
- #call_super(context) ⇒ Object
-
#initialize(tag_name, markup, tokens) ⇒ Block
constructor
A new instance of Block.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, markup, tokens) ⇒ Block
Returns a new instance of Block.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/liquid_blocks/block.rb', line 19 def initialize(tag_name, markup, tokens) @parent = nil 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
#name ⇒ Object (readonly)
Returns the value of attribute name.
17 18 19 |
# File 'lib/liquid_blocks/block.rb', line 17 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
16 17 18 |
# File 'lib/liquid_blocks/block.rb', line 16 def parent @parent end |
Instance Method Details
#add_parent(nodelist) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/liquid_blocks/block.rb', line 39 def add_parent(nodelist) if @parent != nil @parent.add_parent(nodelist) else @parent = Block.parse(@tag_name, @name, Liquid::Tokenizer.new(@name + '{% end' + @tag_name + '%}'), @parse_context) @parent.nodelist.clear nodelist.each {|item| @parent.nodelist << item} end end |
#blank? ⇒ Boolean
49 50 51 |
# File 'lib/liquid_blocks/block.rb', line 49 def blank? false end |
#call_super(context) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/liquid_blocks/block.rb', line 53 def call_super(context) if @parent @parent.render(context) else '' end end |