Class: Twig::Node::Expression::AssignName
- Defined in:
- lib/twig/node/expression/assign_name.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Name
Instance Attribute Summary
Attributes inherited from Base
#attributes, #lineno, #nodes, #source_context, #tag
Instance Method Summary collapse
- #compile(compiler) ⇒ Object
-
#initialize(name, lineno) ⇒ AssignName
constructor
A new instance of AssignName.
Methods included from SupportDefinedTest
#define_test_enabled?, #enable_defined_test
Methods inherited from Base
#explicit_parentheses?, #set_explicit_parentheses
Methods inherited from Base
#empty?, #length, #template_name, #to_s
Constructor Details
#initialize(name, lineno) ⇒ AssignName
Returns a new instance of AssignName.
11 12 13 14 15 16 17 |
# File 'lib/twig/node/expression/assign_name.rb', line 11 def initialize(name, lineno) if %w[true false none null nil].include?(name.downcase) raise Error::Syntax.new("You cannot assign a value to \"#{name}\".", lineno, source_context) end super end |
Instance Method Details
#compile(compiler) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/twig/node/expression/assign_name.rb', line 19 def compile(compiler) compiler. raw('context['). string(attributes[:name]). raw(']') end |