Class: Antlers::YieldNode
- Inherits:
-
BranchNode
- Object
- AntlerNode
- BranchNode
- Antlers::YieldNode
- Defined in:
- lib/nodes/yield_node.rb
Instance Attribute Summary
Attributes inherited from BranchNode
Attributes inherited from AntlerNode
Instance Method Summary collapse
-
#initialize(name: :default) ⇒ YieldNode
constructor
A new instance of YieldNode.
-
#render(current_binding: nil, parent_binding: nil, slot_node: nil, namespace: nil) ⇒ Object
Renders the children of the parent node 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 |
Instance Method Details
#render(current_binding: nil, parent_binding: nil, slot_node: nil, namespace: nil) ⇒ Object
Renders the children of the parent node in the binding of the parent.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nodes/yield_node.rb', line 12 def render(current_binding: nil, parent_binding: nil, slot_node: nil, namespace: nil) output = '' slot_node.children.each do |child| # Antlers nodes respond to "render", whereas HTML is stored as a string and output as is. output += (child.respond_to?(:render) ? child.render(current_binding: parent_binding, parent_binding: nil, slot_node: nil, namespace:) : child) || '' end output end |