Class: Twig::Node::Expression::GetAttribute
- Defined in:
- lib/twig/node/expression/get_attribute.rb
Instance Attribute Summary
Attributes inherited from Base
#attributes, #lineno, #nodes, #source_context, #tag
Instance Method Summary collapse
- #compile(compiler) ⇒ Object
-
#initialize(node, attribute, arguments, type, lineno) ⇒ GetAttribute
constructor
A new instance of GetAttribute.
Methods inherited from Base
#explicit_parentheses?, #set_explicit_parentheses
Methods inherited from Base
Constructor Details
#initialize(node, attribute, arguments, type, lineno) ⇒ GetAttribute
Returns a new instance of GetAttribute.
7 8 9 10 11 12 |
# File 'lib/twig/node/expression/get_attribute.rb', line 7 def initialize(node, attribute, arguments, type, lineno) nodes = { node:, attribute: } nodes[:arguments] = arguments if arguments super(nodes, { type: }, lineno) end |
Instance Method Details
#compile(compiler) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/twig/node/expression/get_attribute.rb', line 14 def compile(compiler) var = compiler.var_name compiler. raw("(#{var} = "). subcompile(nodes[:node]). raw("\n"). write("::Twig::Extension::Core.get_attribute(#{var}, "). subcompile(nodes[:attribute]). raw(', '). repr(attributes[:type]). raw('))') end |