Class: Antlers::BranchNode
- Inherits:
-
AntlerNode
- Object
- AntlerNode
- Antlers::BranchNode
- Defined in:
- lib/interfaces/branch_node.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
Attributes inherited from AntlerNode
Instance Method Summary collapse
-
#initialize(name:, children: []) ⇒ BranchNode
constructor
A new instance of BranchNode.
- #render(current_binding: nil, parent_binding: nil, slot_node: nil, namespace: nil) ⇒ Object
Methods inherited from AntlerNode
Constructor Details
#initialize(name:, children: []) ⇒ BranchNode
Returns a new instance of BranchNode.
9 10 11 12 13 |
# File 'lib/interfaces/branch_node.rb', line 9 def initialize(name:, children: []) super(name:) @children = children end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
7 8 9 |
# File 'lib/interfaces/branch_node.rb', line 7 def children @children end |
Instance Method Details
#render(current_binding: nil, parent_binding: nil, slot_node: nil, namespace: nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/interfaces/branch_node.rb', line 15 def render(current_binding: nil, parent_binding: nil, slot_node: nil, namespace: nil) output = '' @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:, slot_node:, namespace:) : child) || '' end output end |