Class: Antlers::SlotNode
- Inherits:
-
BranchNode
- Object
- AntlerNode
- BranchNode
- Antlers::SlotNode
- Includes:
- Props
- Defined in:
- lib/nodes/slot_node.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
Attributes included from Props
Attributes inherited from AntlerNode
Instance Method Summary collapse
-
#initialize(name:, props: [], children: []) ⇒ SlotNode
constructor
A new instance of SlotNode.
- #render(current_binding: nil, parent_binding: nil, slot_node: nil, namespace: nil) ⇒ Object
Methods inherited from AntlerNode
Constructor Details
#initialize(name:, props: [], children: []) ⇒ SlotNode
Returns a new instance of SlotNode.
12 13 14 |
# File 'lib/nodes/slot_node.rb', line 12 def initialize(name:, props: [], children: []) super(name:, props:, children:) end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
10 11 12 |
# File 'lib/nodes/slot_node.rb', line 10 def children @children end |
Instance Method Details
#render(current_binding: nil, parent_binding: nil, slot_node: nil, namespace: nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/nodes/slot_node.rb', line 16 def render(current_binding: nil, parent_binding: nil, slot_node: nil, namespace: nil) props = evaluate_props(props: @props, current_binding:) event = create_render_event(props:) klass = class_from_namespace(namespace: namespace&.split('::') || [], name: @name) instance = klass.new(event:) # Classes referenced via "<{ ChildNode }>" must implement class/instance render/render_template methods (See LowNode). return instance.render_template(event:, parent_binding: current_binding, slot_node: self, props:) if klass.template props.empty? ? instance.render(event:) : instance.render(event:, **props) end |