Class: Antlers::SlotNode
- Inherits:
-
BranchNode
- Object
- AntlerNode
- BranchNode
- Antlers::SlotNode
- 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:, namespace:, props: [], children: []) ⇒ SlotNode
constructor
A new instance of SlotNode.
- #render(current_binding: nil, parent_binding: nil, slot_node: nil) ⇒ Object
Methods included from Variables
Methods included from Queries
user_defined_string?, wrapped_in?
Methods included from Namespace
#class_constant, #class_from_namespace
Methods inherited from AntlerNode
Constructor Details
#initialize(name:, namespace:, props: [], children: []) ⇒ SlotNode
Returns a new instance of SlotNode.
14 15 16 17 18 |
# File 'lib/nodes/slot_node.rb', line 14 def initialize(name:, namespace:, props: [], children: [], **) super(name:, props:, children:) @namespace = namespace end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
12 13 14 |
# File 'lib/nodes/slot_node.rb', line 12 def children @children end |
Instance Method Details
#render(current_binding: nil, parent_binding: nil, slot_node: nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/nodes/slot_node.rb', line 20 def render(current_binding: nil, parent_binding: nil, slot_node: nil) props = evaluate_props(props: @props, current_binding:) event = create_render_event(props:) # TODO: Get LowLoad to load constants defined in "<{ MyNode }>" syntax so that we can resolve namespace/params on class load. klass = class_constant(namespace: @namespace&.split('::') || [], 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 |