Automatically preserve textareas generated via Rails helpers.

This commit is contained in:
Nathan Weizenbaum 2008-03-02 14:24:29 -08:00
parent cf4013f868
commit d3ba044529
2 changed files with 11 additions and 0 deletions

View File

@ -61,6 +61,12 @@ if defined?(ActionView) and not defined?(Merb::Plugins)
end
alias_method :form_tag_without_haml, :form_tag
alias_method :form_tag, :form_tag_with_haml
def text_area_tag_with_haml(*args)
preserve text_area_tag_without_haml(*args)
end
alias_method :text_area_tag_without_haml, :text_area_tag
alias_method :text_area_tag, :text_area_tag_with_haml
end
module FormHelper

View File

@ -86,6 +86,11 @@ class HelperTest < Test::Unit::TestCase
assert_equal(should_be, result)
end
def test_text_area_tag
assert_equal("<textarea id=\"body\" name=\"body\">Foo&#x000A;Bar&#x000A; Baz&#x000A; Boom</textarea>\n",
render('= text_area_tag "body", "Foo\nBar\n Baz\n Boom"', :action_view))
end
def test_capture_haml
assert_equal("\"<p>13</p>\\n\"\n", render("- foo = capture_haml(13) do |a|\n %p= a\n= foo.dump"))
end