Sha256: 96898d5f5b4fb5a7a5dca7a27ee5cb07aa61eaf8a1c92b34fb0b0d6c43301000

Contents?: true

Size: 684 Bytes

Versions: 11

Compression:

Stored size: 684 Bytes

Contents

require 'hamlit/string_splitter'

module Hamlit
  class Filters
    class Plain < Base
      def compile(node)
        text = node.value[:text]
        text = text.rstrip unless ::Hamlit::HamlUtil.contains_interpolation?(text) # for compatibility
        [:multi, *compile_plain(text)]
      end

      private

      def compile_plain(text)
        string_literal = ::Hamlit::HamlUtil.unescape_interpolation(text)
        StringSplitter.compile(string_literal).map do |temple|
          type, str = temple
          case type
          when :dynamic
            [:escape, true, [:dynamic, str]]
          else
            temple
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
hamlit-2.2.4 lib/hamlit/filters/plain.rb
hamlit-2.6.1 lib/hamlit/filters/plain.rb
hamlit-2.6.0 lib/hamlit/filters/plain.rb
hamlit-2.5.0 lib/hamlit/filters/plain.rb
hamlit-2.4.2 lib/hamlit/filters/plain.rb
hamlit-2.4.1 lib/hamlit/filters/plain.rb
hamlit-2.4.0 lib/hamlit/filters/plain.rb
hamlit-2.3.1 lib/hamlit/filters/plain.rb
hamlit-2.3.0 lib/hamlit/filters/plain.rb
hamlit-2.2.3 lib/hamlit/filters/plain.rb
hamlit-2.2.2 lib/hamlit/filters/plain.rb