Sha256: 1400a60fac8a839a4ee7993c47f10973b29bad86b5bce0e3a8bca3d137e2d61c

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

# sprockets-sass implements an image_url function that calls over to image_path. But bootstrap-sass
# defines an image_path function that calls image_url! To avoid the probem in bootstrap-sass (and anyone
# who tries something similar, this redefines sprockets-sass' function to not refer to image_path.
#
# See https://github.com/middleman/middleman/issues/864 for more info.
#
module Sass::Script::Functions
  def image_url(source, options = {}, cache_buster = nil)
    # Work with the Compass #image_url API
    if options.respond_to? :value
      case options.value
      when true
        return ::Sass::Script::String.new sprockets_context.image_path(source.value).to_s, :string
      else
        options = {}
      end
    end
    ::Sass::Script::String.new "url(\"#{sprockets_context.image_path(source.value, map_options(options)).to_s}\")"
  end

  # Also override generated_image_url to use Sprockets a la https://github.com/Compass/compass-rails/blob/98e4b115c8bb6395a1c3351926d574321396778b/lib/compass-rails/patches/3_1.rb
  def generated_image_url(path, only_path = nil)
    asset_url(path, Sass::Script::String.new("image"))
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
middleman-sprockets-3.2.0 lib/middleman-sprockets/sass_function_hack.rb
middleman-sprockets-3.1.4 lib/middleman-sprockets/sass_function_hack.rb
middleman-sprockets-3.1.2 lib/middleman-sprockets/sass_function_hack.rb
middleman-sprockets-3.1.1 lib/middleman-sprockets/sass_function_hack.rb