Class: Twig::Node::Expression::Function
- Includes:
- SupportDefinedTest
- Defined in:
- lib/twig/node/expression/function.rb
Instance Attribute Summary
Attributes inherited from Base
#attributes, #lineno, #nodes, #source_context, #tag
Instance Method Summary collapse
- #compile(compiler) ⇒ Object
- #enable_defined_test ⇒ Object
-
#initialize(function, arguments, lineno) ⇒ Function
constructor
A new instance of Function.
Methods included from SupportDefinedTest
Methods inherited from Base
#explicit_parentheses?, #set_explicit_parentheses
Methods inherited from Base
#empty?, #length, #template_name, #to_s
Constructor Details
#initialize(function, arguments, lineno) ⇒ Function
Returns a new instance of Function.
12 13 14 15 16 17 18 19 |
# File 'lib/twig/node/expression/function.rb', line 12 def initialize(function, arguments, lineno) super({ arguments: }, { name: function.name, type: :function, twig_callable: function, is_defined_test: false, }, lineno) end |
Instance Method Details
#compile(compiler) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/twig/node/expression/function.rb', line 27 def compile(compiler) if attributes[:name] == 'constant' && define_test_enabled? nodes[:arguments].nodes[:defined_test] = Expression::Constant.new(true, lineno) end super end |
#enable_defined_test ⇒ Object
21 22 23 24 25 |
# File 'lib/twig/node/expression/function.rb', line 21 def enable_defined_test if attributes[:name] == 'constant' super end end |