mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Fix a long-standing case-parsing bug.
Thanks to Aman Gupta for the bug report.
This commit is contained in:
parent
68bd782b63
commit
9817621ede
2 changed files with 37 additions and 3 deletions
|
@ -209,9 +209,11 @@ END
|
||||||
|
|
||||||
push_silent(text[1..-1], true)
|
push_silent(text[1..-1], true)
|
||||||
newline_now
|
newline_now
|
||||||
if (@block_opened && !mid_block_keyword?(text)) || text[1..-1].split(' ', 2)[0] == "case"
|
|
||||||
push_and_tabulate([:script])
|
case_stmt = text[1..-1].split(' ', 2)[0] == "case"
|
||||||
end
|
block = @block_opened && !mid_block_keyword?(text)
|
||||||
|
push_and_tabulate([:script]) if block || case_stmt
|
||||||
|
push_and_tabulate(nil) if block && case_stmt
|
||||||
when FILTER; start_filtered(text[1..-1].downcase)
|
when FILTER; start_filtered(text[1..-1].downcase)
|
||||||
when DOCTYPE
|
when DOCTYPE
|
||||||
return render_doctype(text) if text[0...3] == '!!!'
|
return render_doctype(text) if text[0...3] == '!!!'
|
||||||
|
@ -371,6 +373,7 @@ END
|
||||||
when :loud; close_loud value
|
when :loud; close_loud value
|
||||||
when :filtered; close_filtered value
|
when :filtered; close_filtered value
|
||||||
when :haml_comment; close_haml_comment
|
when :haml_comment; close_haml_comment
|
||||||
|
when nil; close_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -420,6 +423,10 @@ END
|
||||||
@template_tabs -= 1
|
@template_tabs -= 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def close_nil
|
||||||
|
@template_tabs -= 1
|
||||||
|
end
|
||||||
|
|
||||||
# Iterates through the classes and ids supplied through <tt>.</tt>
|
# Iterates through the classes and ids supplied through <tt>.</tt>
|
||||||
# and <tt>#</tt> syntax, and returns a hash with them as attributes,
|
# and <tt>#</tt> syntax, and returns a hash with them as attributes,
|
||||||
# that can then be merged with another attributes hash.
|
# that can then be merged with another attributes hash.
|
||||||
|
|
|
@ -198,6 +198,33 @@ RESULT
|
||||||
SOURCE
|
SOURCE
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Mostly a regression test
|
||||||
|
def test_both_case_indentation_work_with_deeply_nested_code
|
||||||
|
result = <<RESULT
|
||||||
|
<h2>
|
||||||
|
other
|
||||||
|
</h2>
|
||||||
|
RESULT
|
||||||
|
assert_equal(result, render(<<HAML))
|
||||||
|
- case 'other'
|
||||||
|
- when 'test'
|
||||||
|
%h2
|
||||||
|
hi
|
||||||
|
- when 'other'
|
||||||
|
%h2
|
||||||
|
other
|
||||||
|
HAML
|
||||||
|
assert_equal(result, render(<<HAML))
|
||||||
|
- case 'other'
|
||||||
|
- when 'test'
|
||||||
|
%h2
|
||||||
|
hi
|
||||||
|
- when 'other'
|
||||||
|
%h2
|
||||||
|
other
|
||||||
|
HAML
|
||||||
|
end
|
||||||
|
|
||||||
# HTML escaping tests
|
# HTML escaping tests
|
||||||
|
|
||||||
def test_ampersand_equals_should_escape
|
def test_ampersand_equals_should_escape
|
||||||
|
|
Loading…
Reference in a new issue