[Haml] Allow newlines between case and when.
Closes gh-289
This commit is contained in:
parent
7570cda22f
commit
ff1571831c
|
@ -3,6 +3,10 @@
|
|||
* Table of contents
|
||||
{:toc}
|
||||
|
||||
## 3.0.22 (Unreleased)
|
||||
|
||||
* Allow an empty line after `case` but before `when`.
|
||||
|
||||
## 3.0.21
|
||||
|
||||
[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.21).
|
||||
|
|
|
@ -336,12 +336,14 @@ END
|
|||
end
|
||||
end
|
||||
|
||||
@precompiled <<
|
||||
if @options[:ugly]
|
||||
"_hamlout.buffer << \"#{str}\";"
|
||||
else
|
||||
"_hamlout.push_text(\"#{str}\", #{mtabs}, #{@dont_tab_up_next_text.inspect});"
|
||||
end
|
||||
unless str.empty?
|
||||
@precompiled <<
|
||||
if @options[:ugly]
|
||||
"_hamlout.buffer << \"#{str}\";"
|
||||
else
|
||||
"_hamlout.push_text(\"#{str}\", #{mtabs}, #{@dont_tab_up_next_text.inspect});"
|
||||
end
|
||||
end
|
||||
@precompiled << "\n" * newlines
|
||||
@to_merge = []
|
||||
@dont_tab_up_next_text = false
|
||||
|
|
|
@ -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 \#{raise 'foo'}" => ["foo", 5],
|
||||
"= raise 'foo'\nfoo\nbar\nbaz\nbang" => ["foo", 1],
|
||||
"- case 1\n\n- when 1\n - raise 'foo'" => ["foo", 4],
|
||||
}
|
||||
|
||||
User = Struct.new('User', :id)
|
||||
|
@ -774,6 +775,30 @@ HTML
|
|||
HAML
|
||||
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
|
||||
assert_equal(<<HTML, render(<<HAML, :escape_html => true))
|
||||
foo,
|
||||
|
|
Loading…
Reference in New Issue