Skip to content

Commit

Permalink
html2haml: fix HTML entities being escaped in erb blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Oct 16, 2008
1 parent cc9d768 commit 6d8feeb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/haml/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ class ::Hpricot::Elem
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'))
Expand Down
5 changes: 5 additions & 0 deletions test/haml/html2haml_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ def test_rhtml
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

Expand Down

0 comments on commit 6d8feeb

Please sign in to comment.