mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Haml] [html2haml] Properly handle multiline ERB.
This commit is contained in:
parent
653d96c9bb
commit
f73783ed47
3 changed files with 26 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue