Skip to content

Commit

Permalink
Fix custom importer and avoid mutex lock for custom functions (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntkme committed Jan 30, 2024
1 parent 4735b4a commit 8be9431
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/sassc/rails/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ module Rails
class SassTemplate < Sprockets::SassProcessor
def initialize(options = {}, &block) # rubocop:disable Lint/MissingSuper
@cache_version = options[:cache_version]
@cache_key = "#{self.class.name}:#{VERSION}:#{SassC::VERSION}:#{@cache_version}"
# @importer_class = options[:importer] || Sass::Importers::Filesystem
@cache_key = "#{self.class.name}:#{VERSION}:#{::SassC::VERSION}:#{@cache_version}"
@importer_class = options[:importer] || ::SassC::Rails::Importer
@sass_config = options[:sass_config] || {}
@functions = Module.new do
include ::SassC::Script::Functions
include Functions
include options[:functions] if options[:functions]
class_eval(&block) if block_given?
Expand All @@ -27,7 +28,8 @@ def call(input)
line_comments: line_comments?,
syntax: self.class.syntax,
load_paths: input[:environment].paths,
importer: SassC::Rails::Importer,
functions: @functions,
importer: @importer_class,
sprockets: {
context: context,
environment: input[:environment],
Expand All @@ -37,9 +39,7 @@ def call(input)

engine = ::SassC::Engine.new(input[:data], options)

css = Sprockets::Utils.module_include(::SassC::Script::Functions, @functions) do
engine.render
end
css = engine.render

context.metadata.merge(data: css)
end
Expand Down

0 comments on commit 8be9431

Please sign in to comment.