From a23ac07c57909592812cf4bbbff53fda89b01aa0 Mon Sep 17 00:00:00 2001 From: pavel Date: Wed, 2 Oct 2019 20:31:05 +0200 Subject: [PATCH] pass functions directly --- lib/sprockets/sassc_processor.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/sprockets/sassc_processor.rb b/lib/sprockets/sassc_processor.rb index 2a221f51e..1d0249851 100644 --- a/lib/sprockets/sassc_processor.rb +++ b/lib/sprockets/sassc_processor.rb @@ -42,6 +42,7 @@ def initialize(options = {}, &block) @cache_key = "#{self.class.name}:#{VERSION}:#{Autoload::SassC::VERSION}:#{@cache_version}".freeze @importer_class = options[:importer] @sass_config = options[:sass_config] || {} + @include_module_functions = Gem::Version.new(Autoload::SassC::VERSION) < Gem::Version.new('2.3.0') @functions = Module.new do include Functions include options[:functions] if options[:functions] @@ -53,11 +54,17 @@ def call(input) context = input[:environment].context_class.new(input) options = engine_options(input, context) + options[:functions] = @functions engine = Autoload::SassC::Engine.new(input[:data], options) - css = Utils.module_include(Autoload::SassC::Script::Functions, @functions) do - engine.render.sub(/^\n^\/\*# sourceMappingURL=.*\*\/$/m, '') + css = if @include_module_functions + Utils.module_include(Autoload::SassC::Script::Functions, @functions) do + engine.render + end + else + engine.render end + css = css.sub(/^\n^\/\*# sourceMappingURL=.*\*\/$/m, '') begin map = SourceMapUtils.format_source_map(JSON.parse(engine.source_map), input)