Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: pass functions directly #630

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/sprockets/sassc_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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)
Expand Down