Class: Twig::Node::Expression::Test::Defined
- Defined in:
- lib/twig/node/expression/test/defined.rb
Overview
Checks if an expression is defined
{{ var is defined }}
Instance Attribute Summary
Attributes inherited from Base
#attributes, #lineno, #nodes, #source_context, #tag
Instance Method Summary collapse
- #compile(compiler) ⇒ Object
-
#initialize(node, name, arguments, lineno) ⇒ Defined
constructor
A new instance of Defined.
Methods inherited from Base
#explicit_parentheses?, #set_explicit_parentheses
Methods inherited from Base
#empty?, #length, #template_name, #to_s
Constructor Details
#initialize(node, name, arguments, lineno) ⇒ Defined
Returns a new instance of Defined.
15 16 17 18 19 20 21 22 23 |
# File 'lib/twig/node/expression/test/defined.rb', line 15 def initialize(node, name, arguments, lineno) unless node.is_a?(SupportDefinedTest) raise Error::Syntax.new('The "defined" test only works with simple variables.', lineno) end node.enable_defined_test super end |
Instance Method Details
#compile(compiler) ⇒ Object
25 26 27 28 |
# File 'lib/twig/node/expression/test/defined.rb', line 25 def compile(compiler) compiler. subcompile(nodes[:node]) end |