Class: Twig::Node::Expression::HelperMethod
- Defined in:
- lib/twig/node/expression/helper_method.rb
Instance Attribute Summary
Attributes inherited from Base
#attributes, #lineno, #nodes, #source_context, #tag
Instance Method Summary collapse
- #compile(compiler) ⇒ Object
-
#initialize(name, args, lineno) ⇒ HelperMethod
constructor
A new instance of HelperMethod.
Methods inherited from Base
#explicit_parentheses?, #set_explicit_parentheses
Methods inherited from Base
Constructor Details
#initialize(name, args, lineno) ⇒ HelperMethod
Returns a new instance of HelperMethod.
7 8 9 |
# File 'lib/twig/node/expression/helper_method.rb', line 7 def initialize(name, args, lineno) super({ args: }, { name: }, lineno) end |
Instance Method Details
#compile(compiler) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/twig/node/expression/helper_method.rb', line 11 def compile(compiler) compiler. raw("@call_context.#{attributes[:name]}(") nodes[:args].nodes.each do |key, value| unless key.is_a?(Integer) compiler.raw("#{key}: ") end compiler. subcompile(value). raw(',') end compiler. raw(')') end |