Class: Twig::Node::Expression::Name
- Defined in:
- lib/twig/node/expression/name.rb
Direct Known Subclasses
Constant Summary collapse
- SPECIAL_VARS =
{ '_self' => 'get_template_name', '_context' => 'context', '_charset' => 'env.charset', }.freeze
Instance Attribute Summary
Attributes inherited from Base
#attributes, #lineno, #nodes, #source_context, #tag
Instance Method Summary collapse
- #compile(compiler) ⇒ Object
-
#initialize(name, lineno) ⇒ Name
constructor
A new instance of Name.
Methods inherited from Base
#explicit_parentheses?, #set_explicit_parentheses
Methods inherited from Base
Constructor Details
#initialize(name, lineno) ⇒ Name
Returns a new instance of Name.
15 16 17 18 19 20 21 22 |
# File 'lib/twig/node/expression/name.rb', line 15 def initialize(name, lineno) super({}, { name:, is_defined_test: false, ignore_strict_check: false, alwways_defined: false, }, lineno) end |
Instance Method Details
#compile(compiler) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/twig/node/expression/name.rb', line 24 def compile(compiler) name = attributes[:name] compiler. raw("(context.key?(:#{name})"). raw(" ? context[:#{name}]"). raw(' : raise("#{'). string(name). raw('} does not exist"))') end |