Sha256: 49d18938ef505df2154e6a53c5e75bfd9436102d1102534fed5e2e58dc66fb10

Contents?: true

Size: 491 Bytes

Versions: 40

Compression:

Stored size: 491 Bytes

Contents

# frozen_string_literal: true
module Hamlit
  class Filters
    class Preserve < Base
      def compile(node)
        text = node.value[:text].rstrip + "\n"
        text = text.gsub("\n", '&#x000A;')
        compile_text(text)
      end

      private

      def compile_text(text)
        if ::Hamlit::HamlUtil.contains_interpolation?(text)
          [:dynamic, ::Hamlit::HamlUtil.unescape_interpolation(text)]
        else
          [:static, text]
        end
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
hamlit-3.0.3-java lib/hamlit/filters/preserve.rb
hamlit-3.0.3 lib/hamlit/filters/preserve.rb
hamlit-3.0.2-java lib/hamlit/filters/preserve.rb
hamlit-3.0.2 lib/hamlit/filters/preserve.rb
hamlit-3.0.1-java lib/hamlit/filters/preserve.rb
hamlit-3.0.1 lib/hamlit/filters/preserve.rb
hamlit-3.0.0-java lib/hamlit/filters/preserve.rb
hamlit-3.0.0 lib/hamlit/filters/preserve.rb
hamlit-2.16.2-java lib/hamlit/filters/preserve.rb
hamlit-2.16.2 lib/hamlit/filters/preserve.rb
hamlit-2.16.1-java lib/hamlit/filters/preserve.rb
hamlit-2.16.1 lib/hamlit/filters/preserve.rb
hamlit-2.16.0-java lib/hamlit/filters/preserve.rb
hamlit-2.16.0 lib/hamlit/filters/preserve.rb
hamlit-2.15.2-java lib/hamlit/filters/preserve.rb
hamlit-2.15.2 lib/hamlit/filters/preserve.rb
hamlit-2.15.1-java lib/hamlit/filters/preserve.rb
hamlit-2.15.1 lib/hamlit/filters/preserve.rb
hamlit-2.15.0-java lib/hamlit/filters/preserve.rb
hamlit-2.15.0 lib/hamlit/filters/preserve.rb