Class: Antlers::VarNode

Inherits:
LeafNode show all
Includes:
Variables
Defined in:
lib/nodes/var_node.rb

Instance Attribute Summary collapse

Attributes inherited from AntlerNode

#name

Instance Method Summary collapse

Methods included from Variables

#evaluate, #fallback

Methods included from Queries

user_defined_string?, wrapped_in?

Methods inherited from AntlerNode

#==, #eql?, #hash

Constructor Details

#initialize(value:, name: :var) ⇒ VarNode

Returns a new instance of VarNode.



14
15
16
17
18
# File 'lib/nodes/var_node.rb', line 14

def initialize(value:, name: :var)
  super(name:)

  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



12
13
14
# File 'lib/nodes/var_node.rb', line 12

def value
  @value
end

Instance Method Details

#render(current_binding: nil, parent_binding: nil, slot_node: nil, namespace: nil) ⇒ Object



20
21
22
# File 'lib/nodes/var_node.rb', line 20

def render(current_binding: nil, parent_binding: nil, slot_node: nil, namespace: nil)
  ERB::Util.html_escape(evaluate(name: @value, current_binding:) || fallback(@value))
end