Make sure %textarea and &= interact properly.

This commit is contained in:
Nathan Weizenbaum 2008-08-04 01:04:50 -04:00
parent 7bd150892c
commit 53508642df
2 changed files with 7 additions and 3 deletions

View File

@ -104,15 +104,15 @@ module Haml
escape_html = false, nuke_inner_whitespace = false)
tabulation = @real_tabs
result = result.to_s.rstrip
result = html_escape(result) if escape_html
if preserve_tag
result = Haml::Helpers.preserve(result)
elsif preserve_script
result = Haml::Helpers.find_and_preserve(result, options[:preserve])
end
result = result.to_s.rstrip
result = html_escape(result) if escape_html
has_newline = result.include?("\n")
if in_tag && !nuke_inner_whitespace && (@options[:ugly] || !has_newline || preserve_tag)
@buffer << result

View File

@ -190,6 +190,10 @@ SOURCE
assert_equal("<p>foo &amp; bar</p>\n", render("%p&= 'foo & bar'", :escape_html => false))
end
def test_ampersand_equals_should_escape_before_preserve
assert_equal("<textarea>foo&#x000A;bar</textarea>\n", render('%textarea&= "foo\nbar"', :escape_html => false))
end
def test_bang_equals_should_not_escape
assert_equal("<p>\n foo & bar\n</p>\n", render("%p\n != 'foo & bar'", :escape_html => true))
end