From 729ccd8adaf292b57c378b3362bde9130da998fb Mon Sep 17 00:00:00 2001 From: Fabian Schwahn Date: Wed, 23 Dec 2015 21:34:12 +0100 Subject: [PATCH 1/2] Add failing test for empty templates --- test/engine_test.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/engine_test.rb b/test/engine_test.rb index 1b325096..612a6a15 100644 --- a/test/engine_test.rb +++ b/test/engine_test.rb @@ -189,5 +189,10 @@ def test_inline_source_maps assert_match /sourceMappingURL/, output assert_match /.foo/, output end + + def test_empty_template + output = Engine.new('').render + assert_equal '', output + end end end From c586f056e0427f3f371bfc13e8f6b3d012c558b2 Mon Sep 17 00:00:00 2001 From: Fabian Schwahn Date: Wed, 23 Dec 2015 21:35:09 +0100 Subject: [PATCH 2/2] short circuit render method if template is empty --- lib/sassc/engine.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/sassc/engine.rb b/lib/sassc/engine.rb index 5b0c8032..1e040753 100644 --- a/lib/sassc/engine.rb +++ b/lib/sassc/engine.rb @@ -17,6 +17,8 @@ def initialize(template, options = {}) end def render + return @template if @template.empty? + data_context = Native.make_data_context(@template) context = Native.data_context_get_context(data_context) native_options = Native.context_get_options(context)