Class: Sablon::Processor::Document::EachLoopHandler
- Inherits:
-
FieldHandler
- Object
- FieldHandler
- Sablon::Processor::Document::EachLoopHandler
- Defined in:
- lib/sablon/processor/document/field_handlers.rb
Overview
Handles each loops in the template
Instance Method Summary collapse
- #build_statement(constructor, field, _options = {}) ⇒ Object
-
#initialize ⇒ EachLoopHandler
constructor
A new instance of EachLoopHandler.
Methods inherited from FieldHandler
Constructor Details
#initialize ⇒ EachLoopHandler
Returns a new instance of EachLoopHandler.
46 47 48 |
# File 'lib/sablon/processor/document/field_handlers.rb', line 46 def initialize super(/([^ ]+):each\(([^ ]+)\)/) end |
Instance Method Details
#build_statement(constructor, field, _options = {}) ⇒ Object
50 51 52 53 54 |
# File 'lib/sablon/processor/document/field_handlers.rb', line 50 def build_statement(constructor, field, = {}) expr_name, item_name = field.expression.match(@pattern).to_a[1..2] block = constructor.consume_block("#{expr_name}:endEach") Statement::Loop.new(Expression.parse(expr_name), item_name, block) end |