Class: Antlers::YieldNode
- Inherits:
-
BranchNode
- Object
- AntlerNode
- BranchNode
- Antlers::YieldNode
- Defined in:
- lib/nodes/yield_node.rb
Constant Summary
Constants inherited from AntlerNode
AntlerNode::DEF_KEY, AntlerNode::END_KEY
Instance Attribute Summary
Attributes inherited from BranchNode
Attributes inherited from AntlerNode
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name: :default) ⇒ YieldNode
constructor
A new instance of YieldNode.
-
#render(current_binding: nil, parent_binding:, slot_node:) ⇒ Object
Render the children in the binding of the parent.
Methods inherited from AntlerNode
Constructor Details
#initialize(name: :default) ⇒ YieldNode
Returns a new instance of YieldNode.
7 8 9 |
# File 'lib/nodes/yield_node.rb', line 7 def initialize(name: :default) super(name:) end |
Class Method Details
.build(segment:) ⇒ Object
27 28 29 |
# File 'lib/nodes/yield_node.rb', line 27 def build(segment:, **) new(name: segment[:slot]) end |
.match?(segment:) ⇒ Boolean
23 24 25 |
# File 'lib/nodes/yield_node.rb', line 23 def match?(segment:) segment[:slot] end |
Instance Method Details
#render(current_binding: nil, parent_binding:, slot_node:) ⇒ Object
Render the children in the binding of the parent.
12 13 14 15 16 17 18 19 20 |
# File 'lib/nodes/yield_node.rb', line 12 def render(current_binding: nil, parent_binding:, slot_node:) output = '' slot_node.children.each do |child| output += child.render(current_binding: parent_binding, parent_binding:, slot_node:) || '' end output end |