Class: Twig::Node::Import
Instance Attribute Summary
Attributes inherited from Base
#attributes, #lineno, #nodes, #source_context, #tag
Instance Method Summary collapse
- #compile(compiler) ⇒ Object
-
#initialize(expr, var, lineno) ⇒ Import
constructor
A new instance of Import.
Methods inherited from Base
#empty?, #length, #template_name, #to_s
Constructor Details
#initialize(expr, var, lineno) ⇒ Import
Returns a new instance of Import.
9 10 11 |
# File 'lib/twig/node/import.rb', line 9 def initialize(expr, var, lineno) super({ expr:, 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 |
# File 'lib/twig/node/import.rb', line 14 def compile(compiler) compiler.subcompile(nodes[:var]) if nodes[:expr].is_a?(Expression::Variable::Context) && nodes[:expr].attributes[:name] == '_self' compiler.raw('self') else compiler. raw('load('). subcompile(nodes[:expr]). raw(', '). repr(lineno). raw(').unwrap') end compiler.raw("\n") end |