Sha256: 1ebbcfbe622e7de84374ca1b30ac81f34967b4dcc6ead5725b6b455ae8bceeb2

Contents?: true

Size: 1.34 KB

Versions: 71

Compression:

Stored size: 1.34 KB

Contents

require 'sass'
require 'sass/script/functions'
require 'sass-rails' if ActiveAdmin::DependencyChecker.rails_3_1?

module ActiveAdmin
  module Sass
    module Helpers

      if ActiveAdmin::DependencyChecker.rails_3_1?
        include ::Sass::Rails::Helpers
      end

      # Provides a helper in SASS to ensure that the paths to image
      # assets are always correct across Rails versions.
      #
      # Example:
      #
      #   background: url(active_admin_image_path('some_image.png')) 0 0 repeat-x;
      #
      # Will result in:
      #
      #   background: url("/images/active_admin/some_image.png") 0 0 repeat-x;
      #
      # Or in Rails 3.1 with asset pipeline enebaled:
      #
      #   background: url("/assets/active_admin/some_image.png") 0 0 repeat-x;
      #
      # @param [Sass::Script::String] asset the path to the image after */active_admin/
      #
      # @return [Sass::Script::String] path to the image
      #
      def active_admin_image_path(asset)
        if ActiveAdmin.use_asset_pipeline?
          asset_path(::Sass::Script::String.new("active_admin/#{asset.value}"), ::Sass::Script::String.new('image'))
        else
          ::Sass::Script::String.new("/images/active_admin/#{asset.value}", true)
        end
      end

    end
  end
end

# Install for use in Sass
Sass::Script::Functions.send :include, ActiveAdmin::Sass::Helpers

Version data entries

71 entries across 71 versions & 3 rubygems

Version Path
activeadmin-0.6.0 lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.64 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.63 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.62 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.61 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.60 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.59 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.58 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.57 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.56 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.50 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.46 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
activeadmin-0.5.1 lib/active_admin/sass/helpers.rb
activeadmin-0.5.0 lib/active_admin/sass/helpers.rb
activeadmin-0.5.0.pre1 lib/active_admin/sass/helpers.rb
activeadmin-0.5.0.pre lib/active_admin/sass/helpers.rb
activeadmin-0.4.4 lib/active_admin/sass/helpers.rb
activeadmin-0.4.3 lib/active_admin/sass/helpers.rb
activeadmin-0.4.2 lib/active_admin/sass/helpers.rb
activeadmin-0.4.1 lib/active_admin/sass/helpers.rb