1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Fix a bug with '= ...' rendering in :ugly mode.

This also ends up tightening some other precompiler and buffer code.
This commit is contained in:
Nathan Weizenbaum 2009-01-23 12:19:24 -08:00
parent dc212eaefb
commit ddd4a99da3
3 changed files with 14 additions and 7 deletions

View file

@ -151,11 +151,8 @@ module Haml
<% if in_tag && !nuke_inner_whitespace %> result = tabs(tabulation) + result <% end %>
end
<% if in_tag && !nuke_inner_whitespace %> result = "\\n" + result <% end %>
<% unless nuke_inner_whitespace %> result << "\\n" <% end %>
<% if in_tag && !nuke_inner_whitespace %>
result << tabs(tabulation-1)
result = "\\n\#{result}\\n\#{tabs(tabulation-1)}"
@real_tabs -= 1
<% end %>
<% if interpolated %> @tabulation = old_tabulation <% end %>

View file

@ -332,6 +332,7 @@ END
unless block_opened?
@to_merge << [:script, no_format ? "#{text}\n" : "#{temp} = #{text}\n#{out}"]
concat_merged_text("\n") unless in_tag || nuke_inner_whitespace
@newlines -= 1
return
end
@ -340,7 +341,8 @@ END
push_silent "#{temp} = #{text}"
newline_now
push_and_tabulate([:loud, "_erbout << #{no_format ? "#{temp}.to_s;" : out}"])
push_and_tabulate([:loud, "_erbout << #{no_format ? "#{temp}.to_s;" : out}",
!(in_tag || nuke_inner_whitespace || @options[:ugly])])
end
# Causes <tt>text</tt> to be evaluated, and Haml::Helpers#find_and_flatten
@ -392,10 +394,11 @@ END
end
# Closes a loud Ruby block.
def close_loud(command)
def close_loud(command, add_newline)
push_silent 'end', true
@precompiled << command
@template_tabs -= 1
concat_merged_text("\n") if add_newline
end
# Closes a filtered block.

View file

@ -266,12 +266,19 @@ HAML
end
def test_equals_block_with_ugly
assert_equal("foo\n", render(<<HAML))
assert_equal("foo\n", render(<<HAML, :ugly => true))
= capture_haml do
foo
HAML
end
def test_plain_equals_with_ugly
assert_equal("foo\nbar\n", render(<<HAML, :ugly => true))
= "foo"
bar
HAML
end
# HTML escaping tests
def test_ampersand_equals_should_escape