Class: Liquid::Extends
Overview
Extends allows designer to use template inheritance
{% extends home %}
{% block content }Hello world{% endblock %}
Constant Summary collapse
- Syntax =
/(#{QuotedFragment}+)/
Constants inherited from Block
Block::ContentOfVariable, Block::FullToken, Block::IsTag, Block::IsVariable
Instance Attribute Summary
Attributes inherited from Tag
Instance Method Summary collapse
- #end_tag ⇒ Object
-
#initialize(tag_name, markup, tokens, context) ⇒ Extends
constructor
A new instance of Extends.
- #prepare_parsing ⇒ Object
Methods inherited from Block
#block_delimiter, #block_name, #create_variable, #parse, #render, #unknown_tag
Methods inherited from Tag
Constructor Details
#initialize(tag_name, markup, tokens, context) ⇒ Extends
Returns a new instance of Extends.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/liquid/tags/extends.rb', line 11 def initialize(tag_name, markup, tokens, context) if markup =~ Syntax @template_name = $1.gsub(/["']/o, '').strip else raise SyntaxError.new("Error in tag 'extends' - Valid syntax: extends [template]") end @context = context @parent_template = parse_parent_template prepare_parsing super end_tag end |
Instance Method Details
#end_tag ⇒ Object
33 34 35 36 37 38 |
# File 'lib/liquid/tags/extends.rb', line 33 def end_tag # replace the nodelist by the new one @nodelist = @parent_template.root.nodelist.clone @parent_template = nil # no need to keep it end |
#prepare_parsing ⇒ Object
29 30 31 |
# File 'lib/liquid/tags/extends.rb', line 29 def prepare_parsing @context.merge!(:blocks => self.find_blocks(@parent_template.root.nodelist)) end |