sass / sassc-ruby

Use libsass with Ruby!
MIT License
367 stars 156 forks source link

allow passing functions directly #162

Closed ahorek closed 4 years ago

ahorek commented 4 years ago

my intention is to fix thread safety problems https://github.com/sass/sassc-ruby/issues/133 and https://github.com/rails/sprockets/issues/581 and eventually remove https://github.com/rails/sprockets/blob/0cb3314368f9f9e84343ebedcc09c7137e920bc4/lib/sprockets/utils.rb#L126

sassc doesn't allow you to use different functions for different contexts easily

you can customize functions by patching Sassc::Script::Functions, but there's a race condition if you do this at runtime

this patch will allow you to pass custom functions like this

module MyModule
  def asset_path(path, _options = {})
  end
end

SassC::Engine.new(sass, style: :compressed).render # default Sassc::Script::Functions
SassC::Engine.new(sass, style: :compressed, functions: MyModule).render # custom

what do you think?

diabolo commented 4 years ago

Any chance for this to be released?