Class: Twig::Node::Expression::Variable::AssignTemplate
- Defined in:
- lib/twig/node/expression/variable/assign_template.rb
Instance Attribute Summary
Attributes inherited from Base
#attributes, #lineno, #nodes, #source_context, #tag
Instance Method Summary collapse
- #compile(compiler) ⇒ Object
-
#initialize(var, global: true) ⇒ AssignTemplate
constructor
A new instance of AssignTemplate.
Methods inherited from Base
#explicit_parentheses?, #set_explicit_parentheses
Methods inherited from Base
#empty?, #length, #template_name, #to_s
Constructor Details
#initialize(var, global: true) ⇒ AssignTemplate
Returns a new instance of AssignTemplate.
10 11 12 |
# File 'lib/twig/node/expression/variable/assign_template.rb', line 10 def initialize(var, global: true) super({ var: }, { global: }, var.lineno) end |
Instance Method Details
#compile(compiler) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/twig/node/expression/variable/assign_template.rb', line 14 def compile(compiler) # @var [Template] var var = nodes[:var] compiler. add_debug_info(self). write('macros['). string(var.name(compiler)). raw('] = ') if attributes[:global] compiler. raw('@macros['). string(var.name(compiler)). raw('] = ') end end |