Sha256: 4dc17ff96091e2e103f16521e73235f4820de132be4fdef1752ba9ce5c3feee3

Contents?: true

Size: 1.18 KB

Versions: 8

Compression:

Stored size: 1.18 KB

Contents

module Sass::Script::Functions
  # similar to asset_path with prefix for current theme asset
  # def theme_path(path, options = {})
  #   asset_path("#{get_theme_prefix}#{path}", options)
  # end

  # similar to asset_url with prefix for current theme asset
  def theme_asset(path, options = {})
    asset_url("#{get_theme_prefix}#{path}", options)
  end

  # # similar to asset_path with prefix for current plugin asset
  # def plugin_path(path, options = {})
  #   asset_path("#{get_plugin_prefix}#{path}", options)
  # end

  # similar to asset_url with prefix for current plugin asset
  def plugin_asset(path, options = {})
    asset_url("#{get_plugin_prefix}#{path}", options)
  end

  private
  # get plugin asset prefix
  def get_plugin_prefix
    file = sprockets_context.filename
    res = ""
    if file.include?("/app/apps/plugins/")
      res = "themes/#{file.split("/app/apps/plugins/").last.split("/").first}/assets/"
    end
    res
  end

  # get theme asset prefix
  def get_theme_prefix
    file = sprockets_context.filename
    res = ""
    if file.include?("/app/apps/themes/")
      res = "themes/#{file.split("/app/apps/themes/").last.split("/").first}/assets/"
    end
    res
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
camaleon_cms-1.0.2 config/initializers/sass.rb
camaleon_cms-1.0.1 config/initializers/sass.rb
camaleon_cms-1.0 config/initializers/sass.rb
camaleon_cms-0.2.1 config/initializers/sass.rb
camaleon_cms-0.2.0 config/initializers/sass.rb
camaleon_cms-0.1.9 config/initializers/sass.rb
camaleon_cms-0.1.8 config/initializers/sass.rb
camaleon_cms-0.1.7 config/initializers/sass.rb