Module: Sprockets::Rails::Context

Includes:
ActionView::Helpers::AssetTagHelper, ActionView::Helpers::AssetUrlHelper
Defined in:
lib/sprockets/rails/context.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



10
11
12
13
14
# File 'lib/sprockets/rails/context.rb', line 10

def self.included(klass)
  klass.class_eval do
    class_attribute :config, :assets_prefix, :digest_assets
  end
end

Instance Method Details

#compute_asset_path(path, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/sprockets/rails/context.rb', line 16

def compute_asset_path(path, options = {})
  @dependencies << 'actioncontroller-asset-url-config'

  begin
    asset_uri = resolve(path)
  rescue FileNotFound
    # TODO: eh, we should be able to use a form of locate that returns
    # nil instead of raising an exception.
  end

  if asset_uri
    asset = link_asset(path)
    digest_path = asset.digest_path
    path = digest_path if digest_assets
    File.join(assets_prefix || "/", path)
  else
    super
  end
end