Sha256: a022d1bc2be0239400ab030d8dab1380158878c4408e70ea7d5c860f9c7cbca3

Contents?: true

Size: 759 Bytes

Versions: 47

Compression:

Stored size: 759 Bytes

Contents

# frozen_string_literal: true
module Haml
  class Filters
    class TextBase < Base
      def compile_text!(temple, node, prefix)
        text = node.value[:text].rstrip.gsub(/^/, prefix)
        if ::Haml::Util.contains_interpolation?(node.value[:text])
          # original: Haml::Filters#compile
          text = ::Haml::Util.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

47 entries across 47 versions & 1 rubygems

Version Path
haml-6.0.11 lib/haml/filters/text_base.rb
haml-6.0.10-java lib/haml/filters/text_base.rb
haml-6.0.10 lib/haml/filters/text_base.rb
haml-6.0.9-java lib/haml/filters/text_base.rb
haml-6.0.9 lib/haml/filters/text_base.rb
haml-6.0.8-java lib/haml/filters/text_base.rb
haml-6.0.8 lib/haml/filters/text_base.rb
haml-6.0.7-java lib/haml/filters/text_base.rb
haml-6.0.7 lib/haml/filters/text_base.rb
haml-6.0.6-java lib/haml/filters/text_base.rb
haml-6.0.6 lib/haml/filters/text_base.rb
haml-6.0.5-java lib/haml/filters/text_base.rb
haml-6.0.5 lib/haml/filters/text_base.rb
haml-6.0.4-java lib/haml/filters/text_base.rb
haml-6.0.4 lib/haml/filters/text_base.rb
haml-6.0.3-java lib/haml/filters/text_base.rb
haml-6.0.3 lib/haml/filters/text_base.rb
haml-6.0.2-java lib/haml/filters/text_base.rb
haml-6.0.2 lib/haml/filters/text_base.rb
haml-6.0.1-java lib/haml/filters/text_base.rb