Skip to content

Commit

Permalink
define the asset_url function in the right context.
Browse files Browse the repository at this point in the history
  • Loading branch information
botandrose-machine committed May 15, 2020
1 parent 8d0462d commit 9924af6
Showing 1 changed file with 11 additions and 7 deletions.
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

0 comments on commit 9924af6

Please sign in to comment.