[Haml] Fix the multiline/filter issues.

This commit is contained in:
Nathan Weizenbaum 2009-03-21 19:50:15 -07:00
parent 8ea318105c
commit a7867de1f3
2 changed files with 12 additions and 16 deletions

View File

@ -774,8 +774,12 @@ END
end
# `flat?' here is a little outdated,
# so we have to manually check if the previous line closes the flat block.
unless flat? && (@line.text.empty? || @line.tabs >= @template_tabs)
# so we have to manually check if either the previous or current line
# closes the flat block,
# as well as whether a new block is opened
@line.tabs if @line
unless (flat? && !closes_flat?(line) && !closes_flat?(@line)) ||
(@line && @line.text[0] == ?: && line.full =~ %r[^#{@line.full[/^\s+/]}\s])
if line.text.empty?
newline
return next_line
@ -787,6 +791,10 @@ END
@next_line = line
end
def closes_flat?(line)
line && !line.text.empty? && line.full !~ /^#{@flat_spaces}/
end
def un_next_line(line)
@template.unshift line
@template_index -= 1

View File

@ -325,18 +325,6 @@ HTML
HAML
end
def test_multiline_with_colon_after_filter
assert_equal(<<HTML, render(<<HAML))
Foo
Bar
HTML
:plain
Foo
= { :a => "Bar", |
:b => "Baz" }[:a] |
HAML
end
def test_multiline_in_filter
assert_equal(<<HTML, render(<<HAML))
Foo |