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.6 lib/active_admin/sass/helpers.rb
activeadmin-0.6.5 lib/active_admin/sass/helpers.rb
activeadmin-0.6.4 lib/active_admin/sass/helpers.rb
activeadmin-0.6.3 lib/active_admin/sass/helpers.rb
activeadmin-0.6.2 lib/active_admin/sass/helpers.rb
activeadmin-0.6.1 lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.141 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.136 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.135 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.134 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.133 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.132 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.131 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.129 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.128 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.126 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.125 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.124 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.123 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb
lalala-4.0.0.dev.118 vendor/deps/active_admin/lib/active_admin/sass/helpers.rb