Sha256: 14d0281fa2356b1e4df3dad8d42c509e63a6290f4fa519759178587d562c8912

Contents?: true

Size: 1.04 KB

Versions: 16

Compression:

Stored size: 1.04 KB

Contents

module Liquidscript
  module Scanner
    class Liquidscript < Base
      module Heredocs
        include Base::DSL

        define do
          context :heredoc do
            init { @buffer = [] }

            on(%r{\n\s*([A-Z]+)\s*\n}) do |_, s|
              if @start == s
                emit :heredoc, @buffer.join
                exit
              else
                @buffer << _
              end
            end

            on(:_) { |m| @buffer << m }
          end

          context :iheredoc do
            init { @buffer = [] }

            on(%r{\n\s*([A-Z]+)\s*\n}) do |_, s|
              if @start == s
                emit :iheredoc, @buffer.join
                @start = nil
                exit
              else
                @buffer << _
              end
            end

            on(%r{\#\{(.*?)\}}) do |_, b|
              emit :iheredoc_begin, @buffer.join
              lex :main => b
              @buffer = []
            end

            on(:_) { |m| @buffer << m }
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
liquidscript-0.11.0 lib/liquidscript/scanner/liquidscript/heredocs.rb
liquidscript-0.11.0.rc1 lib/liquidscript/scanner/liquidscript/heredocs.rb
liquidscript-0.10.4 lib/liquidscript/scanner/liquidscript/heredocs.rb
liquidscript-0.10.3 lib/liquidscript/scanner/liquidscript/heredocs.rb
liquidscript-0.10.2 lib/liquidscript/scanner/liquidscript/heredocs.rb
liquidscript-0.10.1 lib/liquidscript/scanner/liquidscript/heredocs.rb
liquidscript-0.10.0 lib/liquidscript/scanner/liquidscript/heredocs.rb
liquidscript-0.9.2 lib/liquidscript/scanner/liquidscript/heredocs.rb
liquidscript-0.9.1 lib/liquidscript/scanner/liquidscript/heredocs.rb
liquidscript-0.9.0 lib/liquidscript/scanner/liquidscript/heredocs.rb
liquidscript-0.8.2 lib/liquidscript/scanner/liquidscript/heredocs.rb
liquidscript-0.8.1 lib/liquidscript/scanner/liquidscript/heredocs.rb
liquidscript-0.8.0 lib/liquidscript/scanner/liquidscript/heredocs.rb
liquidscript-0.7.12 lib/liquidscript/scanner/liquidscript/heredocs.rb
liquidscript-0.7.11 lib/liquidscript/scanner/liquidscript/heredocs.rb
liquidscript-0.7.10 lib/liquidscript/scanner/liquidscript/heredocs.rb