Sha256: e7a3cc3e20f3307ddc8df0930bcf5f408b79653e9e79f34b29517368fcf902af

Contents?: true

Size: 496 Bytes

Versions: 36

Compression:

Stored size: 496 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.slow_unescape_interpolation(text)]
        else
          [:static, text]
        end
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
hamlit-2.12.0-java lib/hamlit/filters/preserve.rb
hamlit-2.12.0 lib/hamlit/filters/preserve.rb
hamlit-2.11.1 lib/hamlit/filters/preserve.rb
hamlit-2.11.0-java lib/hamlit/filters/preserve.rb
hamlit-2.11.0 lib/hamlit/filters/preserve.rb
hamlit-2.10.1-java lib/hamlit/filters/preserve.rb
hamlit-2.10.1 lib/hamlit/filters/preserve.rb
hamlit-2.10.0-java lib/hamlit/filters/preserve.rb
hamlit-2.10.0 lib/hamlit/filters/preserve.rb
hamlit-2.9.5-java lib/hamlit/filters/preserve.rb
hamlit-2.9.4-java lib/hamlit/filters/preserve.rb
hamlit-2.9.5 lib/hamlit/filters/preserve.rb
hamlit-2.9.4 lib/hamlit/filters/preserve.rb
hamlit-2.9.3-java lib/hamlit/filters/preserve.rb
hamlit-2.9.3 lib/hamlit/filters/preserve.rb
hamlit-2.9.2-java lib/hamlit/filters/preserve.rb
hamlit-2.9.2 lib/hamlit/filters/preserve.rb
hamlit-2.9.1-java lib/hamlit/filters/preserve.rb
hamlit-2.9.1 lib/hamlit/filters/preserve.rb
hamlit-2.9.0 lib/hamlit/filters/preserve.rb