[Haml] Allow newlines between case and when.

Closes gh-289
This commit is contained in:
Nathan Weizenbaum 2010-10-03 19:06:42 -07:00
parent 7570cda22f
commit ff1571831c
3 changed files with 37 additions and 6 deletions

View File

@ -3,6 +3,10 @@
* Table of contents * Table of contents
{:toc} {:toc}
## 3.0.22 (Unreleased)
* Allow an empty line after `case` but before `when`.
## 3.0.21 ## 3.0.21
[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.21). [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.21).

View File

@ -336,12 +336,14 @@ END
end end
end end
@precompiled << unless str.empty?
if @options[:ugly] @precompiled <<
"_hamlout.buffer << \"#{str}\";" if @options[:ugly]
else "_hamlout.buffer << \"#{str}\";"
"_hamlout.push_text(\"#{str}\", #{mtabs}, #{@dont_tab_up_next_text.inspect});" else
end "_hamlout.push_text(\"#{str}\", #{mtabs}, #{@dont_tab_up_next_text.inspect});"
end
end
@precompiled << "\n" * newlines @precompiled << "\n" * newlines
@to_merge = [] @to_merge = []
@dont_tab_up_next_text = false @dont_tab_up_next_text = false

View File

@ -86,6 +86,7 @@ MESSAGE
"foo\n:plain\n 1\n 2\n 3\#{''}\n4\n- raise 'foo'" => ["foo", 7], "foo\n:plain\n 1\n 2\n 3\#{''}\n4\n- raise 'foo'" => ["foo", 7],
"foo\n:plain\n 1\n 2\n \#{raise 'foo'}" => ["foo", 5], "foo\n:plain\n 1\n 2\n \#{raise 'foo'}" => ["foo", 5],
"= raise 'foo'\nfoo\nbar\nbaz\nbang" => ["foo", 1], "= raise 'foo'\nfoo\nbar\nbaz\nbang" => ["foo", 1],
"- case 1\n\n- when 1\n - raise 'foo'" => ["foo", 4],
} }
User = Struct.new('User', :id) User = Struct.new('User', :id)
@ -774,6 +775,30 @@ HTML
HAML HAML
end end
def test_case_with_newline_after_case
assert_equal(<<HTML, render(<<HAML))
foo
HTML
- case 1
- when 1
foo
- when 2
bar
HAML
assert_equal(<<HTML, render(<<HAML))
bar
HTML
- case 2
- when 1
foo
- when 2
bar
HAML
end
def test_escape_html_with_interpolated_if_statement def test_escape_html_with_interpolated_if_statement
assert_equal(<<HTML, render(<<HAML, :escape_html => true)) assert_equal(<<HTML, render(<<HAML, :escape_html => true))
foo, foo,