Sha256: 9e97c0504e62535cd8b3049a6087fd7e57dd271cd191aeac5992bfbdac1ee4cd

Contents?: true

Size: 778 Bytes

Versions: 36

Compression:

Stored size: 778 Bytes

Contents

# frozen_string_literal: true
module Hamlit
  class Filters
    class TextBase < Base
      def compile_text!(temple, node, prefix)
        text = node.value[:text].rstrip.gsub(/^/, prefix)
        if ::Hamlit::HamlUtil.contains_interpolation?(node.value[:text])
          # original: Haml::Filters#compile
          text = ::Hamlit::HamlUtil.slow_unescape_interpolation(text).gsub(/(\\+)n/) do |s|
            escapes = $1.size
            next s if escapes % 2 == 0
            "#{'\\' * (escapes - 1)}\n"
          end
          text.prepend("\n")
          temple << [:dynamic, text]
        else
          node.value[:text].split("\n").size.times do
            temple << [:newline]
          end
          temple << [: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/text_base.rb
hamlit-2.12.0 lib/hamlit/filters/text_base.rb
hamlit-2.11.1 lib/hamlit/filters/text_base.rb
hamlit-2.11.0-java lib/hamlit/filters/text_base.rb
hamlit-2.11.0 lib/hamlit/filters/text_base.rb
hamlit-2.10.1-java lib/hamlit/filters/text_base.rb
hamlit-2.10.1 lib/hamlit/filters/text_base.rb
hamlit-2.10.0-java lib/hamlit/filters/text_base.rb
hamlit-2.10.0 lib/hamlit/filters/text_base.rb
hamlit-2.9.5-java lib/hamlit/filters/text_base.rb
hamlit-2.9.4-java lib/hamlit/filters/text_base.rb
hamlit-2.9.5 lib/hamlit/filters/text_base.rb
hamlit-2.9.4 lib/hamlit/filters/text_base.rb
hamlit-2.9.3-java lib/hamlit/filters/text_base.rb
hamlit-2.9.3 lib/hamlit/filters/text_base.rb
hamlit-2.9.2-java lib/hamlit/filters/text_base.rb
hamlit-2.9.2 lib/hamlit/filters/text_base.rb
hamlit-2.9.1-java lib/hamlit/filters/text_base.rb
hamlit-2.9.1 lib/hamlit/filters/text_base.rb
hamlit-2.9.0 lib/hamlit/filters/text_base.rb