Class: Twig::Node::ForLoop
Instance Attribute Summary
Attributes inherited from Base
#attributes, #lineno, #nodes, #source_context, #tag
Instance Method Summary collapse
- #compile(compiler) ⇒ Object
-
#initialize(lineno) ⇒ ForLoop
constructor
A new instance of ForLoop.
Methods inherited from Base
#empty?, #length, #template_name, #to_s
Constructor Details
#initialize(lineno) ⇒ ForLoop
Returns a new instance of ForLoop.
6 7 8 |
# File 'lib/twig/node/for_loop.rb', line 6 def initialize(lineno) super({}, { with_loop: false, if_expr: false, else_expr: false }, lineno) end |
Instance Method Details
#compile(compiler) ⇒ Object
10 11 12 13 14 |
# File 'lib/twig/node/for_loop.rb', line 10 def compile(compiler) if attributes.key?(:else_expr) compiler.write("context[:_iterated] = true\n") end end |