[Haml] [html2haml] Properly handle multiline ERB.

This commit is contained in:
Nathan Weizenbaum 2009-10-23 02:27:02 -07:00
parent 653d96c9bb
commit f73783ed47
3 changed files with 26 additions and 2 deletions

View File

@ -113,6 +113,9 @@ including the line number and the offending character.
* Attributes are now sorted, to maintain a deterministic order.
* Multi-line ERB statements are now properly indented,
and those without any content are removed.
## [2.2.7](http://github.com/nex3/haml/commit/2.2.7)
* Fixed an `html2haml` issue where ERB attribute values

View File

@ -232,8 +232,10 @@ module Haml
when "loud"
return output + "= #{CGI.unescapeHTML(inner_text).gsub(/\n\s*/, ' ').strip}\n"
when "silent"
return output + CGI.unescapeHTML(inner_text).split("\n").
map {|line| "- #{line.strip}\n"}.join
return CGI.unescapeHTML(inner_text).split("\n").map do |line|
next "" if line.strip.empty?
"#{output}- #{line.strip}\n"
end.join
when "block"
return render_children("", tabs, options)
end

View File

@ -316,6 +316,25 @@ HTML
render_erb('<p foo="<%= "#{bar} baz" %>"></p>'))
end
def test_multiline_erb_silent_script
assert_equal(<<HAML.rstrip, render_erb(<<ERB))
.blah
- foo
- bar
- baz
%p foo
HAML
<div class="blah">
<%
foo
bar
baz
%>
<p>foo</p>
</div>
ERB
end
### Block Parsing
def test_block_parsing