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 segfault by defining the asset_url function in the right context #148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 11 additions & 7 deletions lib/sassc/rails/functions.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# frozen_string_literal: true

require 'sprockets/sass_functions'
begin
require 'sprockets/sassc_processor'
mod = Sprockets::SasscProcessor::Functions
rescue LoadError
require 'sprockets/sass_functions'
mod = Sprockets::SassFunctions
end

module Sprockets
module SassFunctions
def asset_data_url(path)
::SassC::Script::Value::String.new("url(" + sprockets_context.asset_data_uri(path.value) + ")")
end
mod.instance_eval do
def asset_data_url(path)
::SassC::Script::Value::String.new("url(" + sprockets_context.asset_data_uri(path.value) + ")")
end
end

::SassC::Script::Functions.send :include, Sprockets::SassFunctions
::SassC::Script::Functions.send :include, mod