Class: LiquidBlocks::Extends
- Inherits:
-
Liquid::Block
- Object
- Liquid::Block
- LiquidBlocks::Extends
- Defined in:
- lib/liquid_blocks/extends.rb
Constant Summary collapse
- SYNTAX =
/(#{Liquid::QuotedFragment}+)/
Instance Attribute Summary collapse
-
#template_name ⇒ Object
readonly
Returns the value of attribute template_name.
Instance Method Summary collapse
- #blank? ⇒ Boolean
-
#initialize(tag_name, markup, tokens) ⇒ Extends
constructor
A new instance of Extends.
-
#load_template(template_name) ⇒ Liquid::Document
Load the template that is being extended by the current tag.
- #nodelist ⇒ Object
- #parse(tokens) ⇒ Object
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, markup, tokens) ⇒ Extends
Returns a new instance of Extends.
8 9 10 11 12 13 14 15 |
# File 'lib/liquid_blocks/extends.rb', line 8 def initialize(tag_name, markup, tokens) if markup =~ SYNTAX @template_name = $1[1..-2] else raise Liquid::SyntaxError.new("Syntax Error in 'extends' - Valid syntax: extends [template]") end super end |
Instance Attribute Details
#template_name ⇒ Object (readonly)
Returns the value of attribute template_name.
6 7 8 |
# File 'lib/liquid_blocks/extends.rb', line 6 def template_name @template_name end |
Instance Method Details
#blank? ⇒ Boolean
33 34 35 |
# File 'lib/liquid_blocks/extends.rb', line 33 def blank? false end |
#load_template(template_name) ⇒ Liquid::Document
Load the template that is being extended by the current tag.
41 42 43 44 |
# File 'lib/liquid_blocks/extends.rb', line 41 def load_template(template_name) source = Liquid::Template.file_system.read_template_file(template_name) Liquid::Template.parse(source) end |
#nodelist ⇒ Object
29 30 31 |
# File 'lib/liquid_blocks/extends.rb', line 29 def nodelist @body.nodelist end |
#parse(tokens) ⇒ Object
17 18 19 20 |
# File 'lib/liquid_blocks/extends.rb', line 17 def parse(tokens) @body = Liquid::BlockBody.new parse_all(tokens) end |
#render(context) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/liquid_blocks/extends.rb', line 22 def render(context) origin = populate_nodelist(self, context) @body.nodelist.clear origin.root.nodelist.each {|item| @body.nodelist << item} super end |