Sha256: 6ac301636256938c946274e4ec4ad1823b09c78e072dbbf28c01e1eb8131e7d2

Contents?: true

Size: 1.34 KB

Versions: 5

Compression:

Stored size: 1.34 KB

Contents

require 'haml/helpers/action_view_mods'

module ActionView
  module Helpers
    module TagHelper

      # Only preserve whitespace in the tag's content: https://github.com/nex3/haml/pull/503
      def content_tag_with_haml_and_preserve(name, content_or_options_with_block = nil, *args, &block)
        return content_tag_without_haml(name, content_or_options_with_block, *args, &block) unless is_haml?

        preserve = haml_buffer.options[:preserve].include?(name.to_s)

        if block_given?
          if block_is_haml?(block) && preserve
            content_tag_without_haml(name, content_or_options_with_block, *args) {preserve(&block)}
          else
            content_tag_without_haml(name, content_or_options_with_block, *args, &block)
          end
        else
          if name == 'textarea'
            tab_down(haml_buffer.tabulation)
          elsif preserve && content_or_options_with_block
            content_or_options_with_block = Haml::Helpers.preserve(content_or_options_with_block)
          end
          content_tag_without_haml(name, content_or_options_with_block, *args, &block)
        end
      end

      alias_method :content_tag_without_haml_and_preserve, :content_tag
      alias_method :content_tag, :content_tag_with_haml_and_preserve
      alias_method :content_tag_with_haml, :content_tag_with_haml_and_preserve
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
locomotive_cms-2.0.0.rc10 lib/locomotive/haml.rb
locomotive_cms-2.0.0.rc9 lib/locomotive/haml.rb
locomotive_cms-2.0.0.rc8 lib/locomotive/haml.rb
locomotive_cms-2.0.0.rc7 lib/locomotive/haml.rb
locomotive_cms-2.0.0.rc6 lib/locomotive/haml.rb