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

Fix custom importer and avoid mutex lock for custom functions #22

Merged
merged 1 commit into from
Jan 30, 2024
Merged
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
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