Class: Raw::EachMorpher
- Defined in:
- lib/raw/compiler/filter/morph/each.rb
Overview
attribute: each, for
<li each=“item in array”>my item is #item</li>
becomes
<?r for item in array ?>
<li>my item is #{item}</li>
<?r end ?>
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Morpher
#attributes, #key, #name, #value
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Morpher
#after_start, #before_end, #initialize
Constructor Details
This class inherits a constructor from Raw::Morpher
Class Method Details
.key ⇒ Object
16 17 18 |
# File 'lib/raw/compiler/filter/morph/each.rb', line 16 def self.key "each" end |
Instance Method Details
#after_end(buffer) ⇒ Object
27 28 29 30 31 |
# File 'lib/raw/compiler/filter/morph/each.rb', line 27 def after_end(buffer) if @value =~ / in / buffer << " <?r end ?>" end end |
#before_start(buffer) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/raw/compiler/filter/morph/each.rb', line 20 def before_start(buffer) if @value =~ / in / buffer << "<?r for #@value ?> " attributes.delete(@key) end end |