1
0
Fork 0
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:
Takashi Kokubun 2015-03-16 00:08:08 +09:00
parent 1074875d73
commit a758dcd233
3 changed files with 18 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -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