From c32fa3c3356d3f4c1df73518910f46ea5f5d9fda Mon Sep 17 00:00:00 2001 From: Will Jordan Date: Sat, 10 Mar 2018 02:00:47 -0800 Subject: [PATCH] fix error on empty :javascript and :css filter blocks (#986) Fixes #985. --- lib/haml/filters.rb | 2 +- test/filters_test.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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