[Haml] Fix the multiline/filter issues.
This commit is contained in:
parent
8ea318105c
commit
a7867de1f3
|
@ -774,8 +774,12 @@ END
|
||||||
end
|
end
|
||||||
|
|
||||||
# `flat?' here is a little outdated,
|
# `flat?' here is a little outdated,
|
||||||
# so we have to manually check if the previous line closes the flat block.
|
# so we have to manually check if either the previous or current line
|
||||||
unless flat? && (@line.text.empty? || @line.tabs >= @template_tabs)
|
# 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?
|
if line.text.empty?
|
||||||
newline
|
newline
|
||||||
return next_line
|
return next_line
|
||||||
|
@ -787,6 +791,10 @@ END
|
||||||
@next_line = line
|
@next_line = line
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def closes_flat?(line)
|
||||||
|
line && !line.text.empty? && line.full !~ /^#{@flat_spaces}/
|
||||||
|
end
|
||||||
|
|
||||||
def un_next_line(line)
|
def un_next_line(line)
|
||||||
@template.unshift line
|
@template.unshift line
|
||||||
@template_index -= 1
|
@template_index -= 1
|
||||||
|
|
|
@ -325,18 +325,6 @@ HTML
|
||||||
HAML
|
HAML
|
||||||
end
|
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
|
def test_multiline_in_filter
|
||||||
assert_equal(<<HTML, render(<<HAML))
|
assert_equal(<<HTML, render(<<HAML))
|
||||||
Foo |
|
Foo |
|
||||||
|
|
Loading…
Reference in New Issue