File: compass_functions.rb

package info (click to toggle)
ruby-rails-admin 0.8.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,492 kB
  • ctags: 1,292
  • sloc: ruby: 5,341; makefile: 3
file content (28 lines) | stat: -rwxr-xr-x 818 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module Sass
  module Script
    module Functions
      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 = source.value.gsub('"', '')
          Sass::Script::String.new("/images/#{asset_sans_quotes}", :string)
        end
      end

    protected

      def sprockets_context # :nodoc:
        if options.key?(:sprockets)
          options[:sprockets][:context]
        else
          # Compatibility with sprockets pre 2.10.0
          options[:importer].context
        end
      end
    end
  end
end