mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Haml] Allow - if with no content to be followed by - else with content.
Closes gh-62
This commit is contained in:
parent
53e4668775
commit
95f311523e
3 changed files with 26 additions and 1 deletions
|
@ -3,6 +3,15 @@
|
|||
* Table of contents
|
||||
{:toc}
|
||||
|
||||
## 2.2.15 (Unreleased)
|
||||
|
||||
* Allow `if` statements with no content followed by `else` clauses.
|
||||
For example:
|
||||
|
||||
- if foo
|
||||
- else
|
||||
bar
|
||||
|
||||
## [2.2.14](http://github.com/nex3/haml/commit/2.2.14)
|
||||
|
||||
* Don't print warnings when escaping attributes containing non-ASCII characters
|
||||
|
|
|
@ -246,7 +246,13 @@ END
|
|||
# It's important to preserve tabulation modification for keywords
|
||||
# that involve choosing between posible blocks of code.
|
||||
if %w[else elsif when].include?(keyword)
|
||||
@dont_indent_next_line, @dont_tab_up_next_text = @to_close_stack.last[1..2]
|
||||
# @to_close_stack may not have a :script on top
|
||||
# when the preceding "- if" has nothing nested
|
||||
if @to_close_stack.last && @to_close_stack.last.first == :script
|
||||
@dont_indent_next_line, @dont_tab_up_next_text = @to_close_stack.last[1..2]
|
||||
else
|
||||
push_and_tabulate([:script, @dont_indent_next_line, @dont_tab_up_next_text])
|
||||
end
|
||||
|
||||
# when is unusual in that either it will be indented twice,
|
||||
# or the case won't have created its own indentation
|
||||
|
|
|
@ -581,6 +581,16 @@ HTML
|
|||
HAML
|
||||
end
|
||||
|
||||
def test_if_without_content_and_else
|
||||
assert_equal(<<HTML, render(<<HAML))
|
||||
foo
|
||||
HTML
|
||||
- if false
|
||||
- else
|
||||
foo
|
||||
HAML
|
||||
end
|
||||
|
||||
# HTML escaping tests
|
||||
|
||||
def test_ampersand_equals_should_escape
|
||||
|
|
Loading…
Reference in a new issue