Class: Twig::Node::Expression::Function

Inherits:
Call show all
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

Methods included from SupportDefinedTest

#define_test_enabled?

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.

Parameters:



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_testObject



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