Sha256: ade00eccd4155d3e906ea806554a9503660a845f95573f7657b8db5c40f58988

Contents?: true

Size: 1.41 KB

Versions: 10

Compression:

Stored size: 1.41 KB

Contents

module Sass
  module Rails
    module Helpers

      def asset_data_url(path)
        data = context_asset_data_uri(path.value)
        Sass::Script::String.new(%Q{url(#{data})})
      end

      def asset_path(asset, kind)
        Sass::Script::String.new(public_path(asset.value, kind.value), true)
      end

      def asset_url(asset, kind)
        Sass::Script::String.new(%Q{url(#{public_path(asset.value, kind.value)})})
      end

      [:image, :video, :audio, :javascript, :stylesheet].each do |asset_class|
        class_eval %Q{
          def #{asset_class}_path(asset)
            Sass::Script::String.new(resolver.#{asset_class}_path(asset.value), true)
          end
          def #{asset_class}_url(asset)
            Sass::Script::String.new("url(" + resolver.#{asset_class}_path(asset.value) + ")")
          end
        }, __FILE__, __LINE__ - 6
      end

      def font_path(asset)
        asset_path(asset, Sass::Script::String.new("font"))
      end

      def font_url(asset)
        asset_url(asset, Sass::Script::String.new("font"))
      end

    protected

    def resolver
      options[:custom][:resolver]
    end

    def public_path(asset, kind)
      resolver.public_path(asset, kind.pluralize)
    end

    def context_asset_data_uri(path)
      resolver.context.asset_data_uri(path)
    end
    end
  end
end

module Sass
  module Script
    module Functions
      include Sass::Rails::Helpers
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
sass-rails-3.1.7 lib/sass/rails/helpers.rb
sass-rails-3.1.6 lib/sass/rails/helpers.rb
sass-rails-3.2.2 lib/sass/rails/helpers.rb
sass-rails-3.2.1 lib/sass/rails/helpers.rb
sass-rails-3.2.0 lib/sass/rails/helpers.rb
sass-rails-3.1.5 lib/sass/rails/helpers.rb
sass-rails-3.1.5.rc.2 lib/sass/rails/helpers.rb
sass-rails-3.1.5.rc.1 lib/sass/rails/helpers.rb
sass-rails-3.1.4 lib/sass/rails/helpers.rb
sass-rails-3.1.3 lib/sass/rails/helpers.rb