diff --git a/lib/haml/filters.rb b/lib/haml/filters.rb
index 33902c50..ae40ff6a 100644
--- a/lib/haml/filters.rb
+++ b/lib/haml/filters.rb
@@ -182,7 +182,7 @@ RUBY
return
end
- rendered = Haml::Helpers::find_and_preserve(filter.render_with_options(text, compiler.options), compiler.options[:preserve])
+ rendered = Haml::Helpers::find_and_preserve(filter.render_with_options(text.to_s, compiler.options), compiler.options[:preserve])
push_text("#{rendered.rstrip}\n")
end
end
diff --git a/test/filters_test.rb b/test/filters_test.rb
index 6df69a26..2e65651f 100644
--- a/test/filters_test.rb
+++ b/test/filters_test.rb
@@ -185,6 +185,12 @@ class JavascriptFilterTest < Haml::TestCase
refute_match('//', out)
end
+
+ test "should emit tag on empty block" do
+ html = "\n"
+ haml = ":javascript"
+ assert_equal(html, render(haml))
+ end
end
class CSSFilterTest < Haml::TestCase
@@ -224,6 +230,12 @@ class CSSFilterTest < Haml::TestCase
refute_match('', out)
end
+
+ test "should emit tag on empty block" do
+ html = "\n"
+ haml = ":css"
+ assert_equal(html, render(haml))
+ end
end
class CDATAFilterTest < Haml::TestCase