Class: Twig::TwigFunction
Instance Attribute Summary
Attributes inherited from Callable
#arguments, #callable, #dynamic_name, #name
Instance Method Summary
collapse
Methods inherited from Callable
#needs_charset?, #needs_context?, #needs_environment?, #with_dynamic_arguments
Constructor Details
#initialize(name, callable = nil, options = {}) ⇒ TwigFunction
Returns a new instance of TwigFunction.
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/twig/twig_function.rb', line 5
def initialize(name, callable = nil, options = {})
super
@options = {
is_safe: nil,
is_safe_callback: nil,
node_class: Node::Expression::Function,
parser_callable: nil,
}.merge(@options)
end
|
Instance Method Details
#node_class ⇒ Object
33
34
35
|
# File 'lib/twig/twig_function.rb', line 33
def node_class
@options[:node_class]
end
|
#parser_callable ⇒ Proc|nil
29
30
31
|
# File 'lib/twig/twig_function.rb', line 29
def parser_callable
@options[:parser_callable]
end
|
#safe(function_args) ⇒ Object
17
18
19
20
21
22
|
# File 'lib/twig/twig_function.rb', line 17
def safe(function_args)
return @options[:is_safe] unless @options[:is_safe].nil?
return @options[:is_safe_callback].call(function_args) unless @options[:is_safe_callback].nil?
[]
end
|
#type ⇒ Object
24
25
26
|
# File 'lib/twig/twig_function.rb', line 24
def type
:function
end
|