Sha256: e50c8045722b972c58490b198803d942e23237a98faa37470182c1a305985e51

Contents?: true

Size: 523 Bytes

Versions: 6

Compression:

Stored size: 523 Bytes

Contents

require 'temple'

module Faml
  class ScriptEnd < Temple::Filter
    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
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
faml-0.6.0 lib/faml/script_end.rb
faml-0.5.1 lib/faml/script_end.rb
faml-0.5.0 lib/faml/script_end.rb
faml-0.4.2 lib/faml/script_end.rb
faml-0.4.1 lib/faml/script_end.rb
faml-0.4.0 lib/faml/script_end.rb