1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

html2haml: fix HTML entities being escaped in erb blocks

This commit is contained in:
Mislav Marohnić 2008-10-16 10:37:57 +02:00
parent cc9d768e92
commit 6d8feeb378
2 changed files with 6 additions and 2 deletions

View file

@ -131,8 +131,7 @@ module Haml
def to_haml(tabs = 0)
output = "#{tabulate(tabs)}"
if HTML.options[:rhtml] && name[0...5] == 'haml:'
return output + HTML.send("haml_tag_#{name[5..-1]}",
CGI.unescapeHTML(self.innerHTML))
return output + HTML.send("haml_tag_#{name[5..-1]}", CGI.unescapeHTML(self.inner_text))
end
output += "%#{name}" unless name == 'div' && (attributes.include?('id') || attributes.include?('class'))

View file

@ -40,6 +40,11 @@ class Html2HamlTest < Test::Unit::TestCase
assert_equal '= h @item.title', render_rhtml('<%=h @item.title %>')
assert_equal '= h @item.title', render_rhtml('<%=h @item.title -%>')
end
def test_rhtml_with_html_special_chars
assert_equal '= 3 < 5 ? "OK" : "Your computer is b0rken"',
render_rhtml(%Q{<%= 3 < 5 ? "OK" : "Your computer is b0rken" %>})
end
protected