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
-
#initialize(tag_name, markup, tokens) ⇒ Extends
constructor
A new instance of Extends.
-
#load_template(context) ⇒ Liquid::Document
Load the template that is being extended by the current tag.
- #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
#load_template(context) ⇒ Liquid::Document
Load the template that is being extended by the current tag.
30 31 32 33 |
# File 'lib/liquid_blocks/extends.rb', line 30 def load_template(context) source = Liquid::Template.file_system.read_template_file(@template_name, context) Liquid::Template.parse(source) end |
#parse(tokens) ⇒ Object
17 18 19 |
# File 'lib/liquid_blocks/extends.rb', line 17 def parse(tokens) parse_all(tokens) end |
#render(context) ⇒ Object
21 22 23 24 |
# File 'lib/liquid_blocks/extends.rb', line 21 def render(context) origin = populate_nodelist(self, context) origin.render(context) end |