Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't break Haml with textarea newline fix.

See issue #393, issue #4000, issue #5190, and issue #5191. Adds a newline after the textarea opening tag based on @codykrieger's original patch so that we don't cause regressions in Haml-using apps. The regression caused textarea tags to add newlines to the field unintentionally (each update/save added an extra newline.)
  • Loading branch information...
commit 3350ba3b28dddec6603922beefc8c86123b0e933 1 parent e96d04a
@jcoleman authored
View
6 actionpack/lib/action_view/helpers/tag_helper.rb
@@ -17,6 +17,10 @@ module TagHelper
autofocus novalidate formnovalidate open pubdate).to_set
BOOLEAN_ATTRIBUTES.merge(BOOLEAN_ATTRIBUTES.map {|attribute| attribute.to_sym })
+ PRE_CONTENT_STRINGS = {
+ "textarea" => "\n"
+ }
+
# Returns an empty HTML tag of type +name+ which by default is XHTML
# compliant. Set +open+ to true to create an open tag compatible
# with HTML 4.0 and below. Add HTML attributes by passing an attributes
@@ -126,7 +130,7 @@ def escape_once(html)
def content_tag_string(name, content, options, escape = true)
tag_options = tag_options(options, escape) if options
content = ERB::Util.h(content) if escape
- "<#{name}#{tag_options}>#{content}</#{name}>".html_safe
+ "<#{name}#{tag_options}>#{PRE_CONTENT_STRINGS[name]}#{content}</#{name}>".html_safe
end
def tag_options(options, escape = true)
View
2  actionpack/lib/action_view/helpers/tags/text_area.rb
@@ -10,7 +10,7 @@ def render
options["cols"], options["rows"] = size.split("x") if size.respond_to?(:split)
end
- content_tag("textarea", "\n#{options.delete('value') || value_before_type_cast(object)}", options)
+ content_tag("textarea", options.delete('value') || value_before_type_cast(object), options)
end
end
end

0 comments on commit 3350ba3

Please sign in to comment.
Something went wrong with that request. Please try again.