Sha256: 189ae99a872e486bd798567d82b52a54a412a59fe22e22f8430c6d9b913c1721

Contents?: true

Size: 602 Bytes

Versions: 3

Compression:

Stored size: 602 Bytes

Contents

require 'temple'

module FastHaml
  class Newline < Temple::Filter
    def on_multi(*exprs)
      i = exprs.size-1
      marker = false
      while i >= 0
        case exprs[i]
        when [:rmnl]
          if marker
            raise "InternalError: double rmnl error"
          else
            marker = true
            exprs.delete_at(i)
          end
        when [:mknl]
          if marker
            marker = false
            exprs.delete_at(i)
          else
            exprs[i] = [:static, "\n"]
          end
        end
        i -= 1
      end
      [:multi, *exprs]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fast_haml-0.1.10 lib/fast_haml/newline.rb
fast_haml-0.1.9 lib/fast_haml/newline.rb
fast_haml-0.1.8 lib/fast_haml/newline.rb