diff --git a/Rakefile b/Rakefile index 40dca3bc..2b84a6f8 100644 --- a/Rakefile +++ b/Rakefile @@ -9,7 +9,7 @@ desc 'Dumps output to a CSS file for testing' task :debug do require 'sass' require './lib/bootstrap-sass/compass_functions' - require './lib/bootstrap-sass/rails_functions' + require './lib/bootstrap-sass/sass_functions' path = './vendor/assets/stylesheets' %w(bootstrap bootstrap-responsive).each do |file| engine = Sass::Engine.for_file("#{path}/#{file}.scss", syntax: :scss, load_paths: [path]) diff --git a/lib/bootstrap-sass/compass_functions.rb b/lib/bootstrap-sass/compass_functions.rb index d3390bc3..2a33d954 100644 --- a/lib/bootstrap-sass/compass_functions.rb +++ b/lib/bootstrap-sass/compass_functions.rb @@ -1,14 +1,19 @@ # This contains functions for use with a project *only* using Compass. - module Sass::Script::Functions - # Define image_path for Compass to allow use of sprites without url() wrapper. - def image_path(asset) - if defined?(::Compass) - image_url(asset, Sass::Script::Bool.new(true)) + def image_path(source, options = {}) + if defined?(::Sprockets) + ::Sass::Script::String.new sprockets_context.image_path(source.value).to_s, :string + elsif defined?(::Compass) + image_url(source, Sass::Script::Bool.new(true)) else # Revert to the old compass-agnostic path determination - asset_sans_quotes = asset.value.gsub('"', '') + asset_sans_quotes = source.value.gsub('"', '') Sass::Script::String.new("/images/#{asset_sans_quotes}", :string) end end + + protected + def sprockets_context # :nodoc: + options[:custom][:sprockets_context] + end end \ No newline at end of file diff --git a/test/test_helper.rb b/test/test_helper.rb index 021d0d6a..fcbf242f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -4,4 +4,4 @@ require 'test/unit' require 'sass' require 'lib/bootstrap-sass/compass_functions' -require 'lib/bootstrap-sass/rails_functions' \ No newline at end of file +require 'lib/bootstrap-sass/sass_functions' \ No newline at end of file