Sha256: 0e1ec81af3a618e33e4dc494a956c0df28ffb32a54d42921277978629f6f7d54

Contents?: true

Size: 1.6 KB

Versions: 49

Compression:

Stored size: 1.6 KB

Contents

# Rails 3.2.3's form helpers add a newline after opening textareas, which can
# cause problems with newlines being considered content rather than markup.
# These changes fix the issue by making the helpers emit "<haml:newline/>"
# rather than the leading newline. The tag is then replaced by a newline after
# rendering.
#
# This should be considered nothing more than an emergency hotfix to ensure
# compatibility with the latest version of Rails, made at a moment when the Haml
# project is transitioning to a new maintainer.

module AbstractController
  module Rendering
    def render_to_body_with_haml(options = {})
      if rendered = render_to_body_without_haml(options)
        rendered.gsub('<haml:newline/>', "\n").html_safe
      end
    end
    alias_method_chain :render_to_body, :haml
  end
end

module ActionView

  class Renderer
    def render_template_with_haml(context, options)
      if rendered = render_template_without_haml(context, options)
        rendered.gsub('<haml:newline/>', "\n").html_safe
      end
    end
    alias_method_chain :render_template, :haml
  end

  module Helpers
    module TagHelper
      private

      def content_tag_string_with_haml(name, content, options, escape = true)
        if name.to_sym == :textarea
          tag_options = tag_options(options, escape) if options
          content = ERB::Util.h(content) if escape
          "<#{name}#{tag_options}><haml:newline/>#{content}</#{name}>".html_safe
        else
          content_tag_string_without_haml(name, content, options, escape)
        end
      end
      alias_method_chain :content_tag_string, :haml
    end
  end
end

Version data entries

49 entries across 49 versions & 2 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb
classiccms-0.7.4 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb
classiccms-0.7.3 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb
classiccms-0.7.2 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb
classiccms-0.7.1 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb
classiccms-0.7.0 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb
classiccms-0.6.9 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb
classiccms-0.6.8 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb
classiccms-0.6.7 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb
classiccms-0.6.6 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb
classiccms-0.6.5 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb
classiccms-0.6.4 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb
classiccms-0.6.3 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb
classiccms-0.6.2 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb
classiccms-0.6.1 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb
classiccms-0.6.0 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb
classiccms-0.5.17 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb
classiccms-0.5.16 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb
classiccms-0.5.15 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb
classiccms-0.5.14 vendor/bundle/gems/haml-3.1.5/lib/haml/helpers/rails_323_textarea_fix.rb