Sha256: d7ca65f00fafa757eac5db09cd227fc7aba54a60100630fd3903b92d8c38d6a4

Contents?: true

Size: 748 Bytes

Versions: 18

Compression:

Stored size: 748 Bytes

Contents

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

18 entries across 18 versions & 1 rubygems

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