Class: Nitro::EachMorpher

Inherits:
Morpher
  • Object
show all
Defined in:
lib/nitro/compiler/morphing.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 ?>

Instance Method Summary collapse

Methods inherited from Morpher

#after_start, #before_end, #initialize

Constructor Details

This class inherits a constructor from Nitro::Morpher

Instance Method Details

#after_end(buffer) ⇒ Object



79
80
81
82
83
# File 'lib/nitro/compiler/morphing.rb', line 79

def after_end(buffer)
  if @value =~ / in /
    buffer << " <?r end ?>"
  end
end

#before_start(buffer) ⇒ Object



72
73
74
75
76
77
# File 'lib/nitro/compiler/morphing.rb', line 72

def before_start(buffer)
  if @value =~ / in /
    buffer << "<?r for #@value ?> "
    @attributes.delete(@key)
  end
end