[Haml] Don't replace newlines with semicolons in the ERB filter.

This commit is contained in:
Nathan Weizenbaum 2010-01-29 12:13:57 -08:00
parent a8b9b6ae9d
commit fc26667ae3
3 changed files with 17 additions and 1 deletions

View File

@ -11,6 +11,10 @@
* Add a `--unix-newlines` flag to all executables
for outputting Unix-style newlines on Windows.
* Fix a couple bugs with the `:erb` filter:
make sure error reporting uses the correct line numbers,
and allow multi-line expressions.
## [2.2.17](http://github.com/nex3/haml/commit/2.2.16)
* Fix compilation of HTML5 doctypes when using `html2haml`.

View File

@ -282,7 +282,7 @@ END
def compile(precompiler, text)
return if precompiler.options[:suppress_eval]
src = ::ERB.new(text).src.sub(/^#coding:.*?\n/, '').
sub(/^_erbout = '';/, "").gsub("\n", ';')
sub(/^_erbout = '';/, "")
precompiler.send(:push_silent, src)
end
end

View File

@ -72,6 +72,7 @@ class EngineTest < Test::Unit::TestCase
"/ foo\n\n bar" => ["Illegal nesting: nesting within a tag that already has content is illegal.", 3],
"!!!\n\n bar" => ["Illegal nesting: nesting within a header command is illegal.", 3],
"foo\n:ruby\n 1\n 2\n 3\n- raise 'foo'" => ["foo", 6],
"foo\n:erb\n 1\n 2\n 3\n- raise 'foo'" => ["foo", 6],
"= raise 'foo'\nfoo\nbar\nbaz\nbang" => ["foo", 1],
}
@ -567,6 +568,17 @@ HTML
HAML
end
def test_erb_filter_with_multiline_expr
assert_equal(<<HTML, render(<<HAML))
foobarbaz
HTML
:erb
<%= "foo" +
"bar" +
"baz" %>
HAML
end
def test_silent_script_with_hyphen_case
assert_equal("", render("- 'foo-case-bar-case'"))
end