diff options
author | Chris Eppstein <chris@eppsteins.net> | 2011-06-27 13:48:36 -0700 |
---|---|---|
committer | Chris Eppstein <chris@eppsteins.net> | 2011-06-27 13:48:36 -0700 |
commit | 96137e8bd0a0094d26cc0cf6f86642487a60735f (patch) | |
tree | 377fc0a665c7c84c2c01f3d9cd0534dabc107d3a /actionpack/lib/sprockets | |
parent | 266b80c7b28c7587ab1c75aae6e3288e2f6c1aba (diff) | |
download | rails-96137e8bd0a0094d26cc0cf6f86642487a60735f.tar.gz rails-96137e8bd0a0094d26cc0cf6f86642487a60735f.tar.bz2 rails-96137e8bd0a0094d26cc0cf6f86642487a60735f.zip |
Add asset_url helper and refactor the asset paths so that asset hosts can be used during asset precompilation.
Conflicts:
actionpack/lib/action_view/asset_paths.rb
actionpack/lib/sprockets/helpers/rails_helper.rb
actionpack/test/template/sprockets_helper_test.rb
Diffstat (limited to 'actionpack/lib/sprockets')
-rw-r--r-- | actionpack/lib/sprockets/helpers/rails_helper.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb index 9f1f0f3b68..ef7cf9e051 100644 --- a/actionpack/lib/sprockets/helpers/rails_helper.rb +++ b/actionpack/lib/sprockets/helpers/rails_helper.rb @@ -58,23 +58,28 @@ module Sprockets end.join("\n").html_safe end + def asset_path(source, default_ext = nil, body = false) + source = source.logical_path if source.respond_to?(:logical_path) + path = asset_paths.compute_public_path(source, 'assets', default_ext) + body ? "#{path}?body=1" : path + end + private def debug_assets? params[:debug_assets] == '1' || params[:debug_assets] == 'true' end - def asset_path(source, default_ext = nil, body = false) - source = source.logical_path if source.respond_to?(:logical_path) - path = asset_paths.compute_public_path(source, Rails.application.config.assets.prefix, default_ext, true) - body ? "#{path}?body=1" : path - end - class AssetPaths < ::ActionView::AssetPaths #:nodoc: def compute_public_path(source, dir, ext=nil, include_host=true) super(source, Rails.application.config.assets.prefix, ext, include_host) end + # Return the filesystem path for the source + def compute_source_path(source, ext) + asset_for(source, ext) + end + def asset_for(source, ext) source = source.to_s return nil if is_uri?(source) @@ -104,7 +109,7 @@ module Sprockets # When included in Sprockets::Context, we need to ask the top-level config as the controller is not available def performing_caching? - @config ? @config.perform_caching : Rails.application.config.action_controller.perform_caching + @config ? @config.perform_caching : Rails.application.config.action_controller.perform_caching end end end |