Class: Faml::Newline

Inherits:
Temple::Filter
  • Object
show all
Defined in:
lib/faml/newline.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
# File 'lib/faml/newline.rb', line 6

def on_multi(*exprs)
  i = exprs.size - 1
  marker = false
  while i >= 0
    case exprs[i]
    when [:rmnl]
      marker = true
      exprs.delete_at(i)
    when [:mknl]
      if marker
        marker = false
        exprs.delete_at(i)
      else
        exprs[i] = [:static, "\n"]
      end
    end
    i -= 1
  end
  [:multi, *exprs]
end