Class: Faml::ScriptEnd

Inherits:
Temple::Filter
  • Object
show all
Defined in:
lib/faml/script_end.rb

Instance Method Summary collapse

Instance Method Details

#on_multi(*exprs) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/faml/script_end.rb', line 6

def on_multi(*exprs)
  i = exprs.size - 1
  depth = 0
  while i >= 0
    case exprs[i]
    when [:mkend]
      if depth > 0
        # Cancel :mkend
        depth -= 1
        exprs.delete_at(i)
      else
        exprs[i] = [:code, 'end'.freeze]
      end
    when [:rmend]
      depth += 1
      exprs.delete_at(i)
    end
    i -= 1
  end
  [:multi, *exprs]
end