Class: Liquid2::Node
- Inherits:
-
Object
- Object
- Liquid2::Node
- Defined in:
- lib/liquid2/node.rb
Overview
The base class for all nodes in a Liquid syntax tree.
Direct Known Subclasses
Block, Comment, ConditionalBlock, MultiEqualBlock, Output, Tag
Instance Attribute Summary collapse
-
#blank ⇒ Object
Returns the value of attribute blank.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#block_scope ⇒ Object
Return variables this nodes adds to its block scope.
-
#children(_static_context, include_partials: true) ⇒ Object
Return all children of this node.
-
#expressions ⇒ Object
Return this node's expressions.
-
#initialize(token) ⇒ Node
constructor
A new instance of Node.
-
#partial_scope ⇒ Object
Return information about a partial template loaded by this node.
- #render(_context, _buffer) ⇒ Object
- #render_with_disabled_tag_check(context, buffer) ⇒ Object
-
#template_scope ⇒ Object
Return variables this node adds to the template local scope.
Constructor Details
#initialize(token) ⇒ Node
Returns a new instance of Node.
10 11 12 13 |
# File 'lib/liquid2/node.rb', line 10 def initialize(token) @token = token @blank = true end |
Instance Attribute Details
#blank ⇒ Object
Returns the value of attribute blank.
7 8 9 |
# File 'lib/liquid2/node.rb', line 7 def blank @blank end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/liquid2/node.rb', line 6 def token @token end |
Instance Method Details
#block_scope ⇒ Object
Return variables this nodes adds to its block scope.
39 |
# File 'lib/liquid2/node.rb', line 39 def block_scope = [] |
#children(_static_context, include_partials: true) ⇒ Object
Return all children of this node.
30 |
# File 'lib/liquid2/node.rb', line 30 def children(_static_context, include_partials: true) = [] |
#expressions ⇒ Object
Return this node's expressions.
33 |
# File 'lib/liquid2/node.rb', line 33 def expressions = [] |
#partial_scope ⇒ Object
Return information about a partial template loaded by this node.
42 |
# File 'lib/liquid2/node.rb', line 42 def partial_scope = nil |
#render(_context, _buffer) ⇒ Object
15 16 17 |
# File 'lib/liquid2/node.rb', line 15 def render(_context, _buffer) raise "nodes must implement `render: (RenderContext, String) -> void`" end |
#render_with_disabled_tag_check(context, buffer) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/liquid2/node.rb', line 19 def render_with_disabled_tag_check(context, buffer) if context..empty? || !is_a?(Tag) || !context..include?(@token[1] || raise) return render(context, buffer) end raise DisabledTagError.new("#{@token[1]} is not allowed in this context", @token) end |
#template_scope ⇒ Object
Return variables this node adds to the template local scope.
36 |
# File 'lib/liquid2/node.rb', line 36 def template_scope = [] |