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_variable

Methods inherited from AntlerNode

#==, #eql?, #hash

Constructor Details

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

Returns a new instance of VarNode.



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

def initialize(name: :var, value:)
  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_variable(name: @value, current_binding:) || @value)
end