Sha256: 9ee0d0397cbc9e3181ef5eaeb7e2ca803fd9a440c483292d4583be7190052544

Contents?: true

Size: 466 Bytes

Versions: 18

Compression:

Stored size: 466 Bytes

Contents

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

18 entries across 18 versions & 1 rubygems

Version Path
hamlit-2.2.4 lib/hamlit/filters/preserve.rb
hamlit-2.6.1 lib/hamlit/filters/preserve.rb
hamlit-2.6.0 lib/hamlit/filters/preserve.rb
hamlit-2.5.0 lib/hamlit/filters/preserve.rb
hamlit-2.4.2 lib/hamlit/filters/preserve.rb
hamlit-2.4.1 lib/hamlit/filters/preserve.rb
hamlit-2.4.0 lib/hamlit/filters/preserve.rb
hamlit-2.3.1 lib/hamlit/filters/preserve.rb
hamlit-2.3.0 lib/hamlit/filters/preserve.rb
hamlit-2.2.3 lib/hamlit/filters/preserve.rb
hamlit-2.2.2 lib/hamlit/filters/preserve.rb
hamlit-2.2.1 lib/hamlit/filters/preserve.rb
hamlit-2.2.0 lib/hamlit/filters/preserve.rb
hamlit-2.1.2 lib/hamlit/filters/preserve.rb
hamlit-2.1.1 lib/hamlit/filters/preserve.rb
hamlit-2.1.0 lib/hamlit/filters/preserve.rb
hamlit-2.0.2 lib/hamlit/filters/preserve.rb
hamlit-2.0.1 lib/hamlit/filters/preserve.rb