mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Fix if-else nesing bug
This commit is contained in:
parent
1074875d73
commit
a758dcd233
3 changed files with 18 additions and 1 deletions
|
@ -108,7 +108,7 @@ module Hamlit
|
|||
|
||||
ast = [:multi, ast]
|
||||
ast += with_indented { parse_lines }
|
||||
ast << [:code, 'end'] unless internal_statement?(next_line)
|
||||
ast << [:code, 'end'] unless same_indent?(next_line) && internal_statement?(next_line)
|
||||
ast
|
||||
end
|
||||
|
||||
|
|
|
@ -84,6 +84,11 @@ module Hamlit
|
|||
|
||||
tokens
|
||||
end
|
||||
|
||||
def same_indent?(line)
|
||||
return false unless line
|
||||
count_indent(line) == @current_indent
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -67,6 +67,18 @@ describe Hamlit::Engine do
|
|||
HTML
|
||||
end
|
||||
|
||||
it 'accept if inside if-else' do
|
||||
assert_render(<<-'HAML', <<-HTML)
|
||||
- if false
|
||||
- if true
|
||||
ng
|
||||
- else
|
||||
ok
|
||||
HAML
|
||||
ok
|
||||
HTML
|
||||
end
|
||||
|
||||
it 'renders if-elsif' do
|
||||
assert_render(<<-HAML, <<-HTML)
|
||||
- if false
|
||||
|
|
Loading…
Add table
Reference in a new issue