Sha256: f65b4c32e69ef70bb6fa5bf88918a0bfcceebb8ba9848bddc9dba81ae123dc21

Contents?: true

Size: 714 Bytes

Versions: 1

Compression:

Stored size: 714 Bytes

Contents

# frozen_string_literal: true
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

1 entries across 1 versions & 1 rubygems

Version Path
hamlit-2.6.2 lib/hamlit/filters/plain.rb