From 6d8feeb378441237bada08420078a093f1c71598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 16 Oct 2008 10:37:57 +0200 Subject: [PATCH] html2haml: fix HTML entities being escaped in erb blocks --- lib/haml/html.rb | 3 +-- test/haml/html2haml_test.rb | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/haml/html.rb b/lib/haml/html.rb index e7f063aa..da3c6ea8 100644 --- a/lib/haml/html.rb +++ b/lib/haml/html.rb @@ -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')) diff --git a/test/haml/html2haml_test.rb b/test/haml/html2haml_test.rb index 0132e12f..9eb6a79b 100644 --- a/test/haml/html2haml_test.rb +++ b/test/haml/html2haml_test.rb @@ -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