diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-09-24 09:18:30 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-09-24 09:18:30 +0000 |
commit | 7f9a6c0d92105380a036dad2551ed952c47b2210 (patch) | |
tree | 7809137792ebb2f1fe90dcc454a188e50861d0c2 /actionpack | |
parent | 8db51ee3c0d3e2f339da5537177b38129c5d21fa (diff) | |
download | rails-7f9a6c0d92105380a036dad2551ed952c47b2210.tar.gz rails-7f9a6c0d92105380a036dad2551ed952c47b2210.tar.bz2 rails-7f9a6c0d92105380a036dad2551ed952c47b2210.zip |
Cache computed public asset paths.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7611 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/helpers/asset_tag_helper.rb | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index 4306e48343..fd311fadfc 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -384,27 +384,31 @@ module ActionView # a single or wildcarded asset host, if configured, with the correct # request protocol. def compute_public_path(source, dir, ext = nil, include_host = true) - source += ".#{ext}" if File.extname(source).blank? && ext + @@computed_public_paths ||= {} + @@computed_public_paths["#{@controller.request.protocol}#{@controller.request.relative_url_root}#{dir}#{source}#{ext}#{include_host}"] ||= + begin + source += ".#{ext}" if File.extname(source).blank? && ext - if source =~ %r{^[-a-z]+://} - source - else - source = "/#{dir}/#{source}" unless source[0] == ?/ - source = "#{@controller.request.relative_url_root}#{source}" - rewrite_asset_path!(source) + if source =~ %r{^[-a-z]+://} + source + else + source = "/#{dir}/#{source}" unless source[0] == ?/ + source = "#{@controller.request.relative_url_root}#{source}" + rewrite_asset_path!(source) - if include_host - host = compute_asset_host(source) + if include_host + host = compute_asset_host(source) - unless host.blank? or host =~ %r{^[-a-z]+://} - host = "#{@controller.request.protocol}#{host}" - end + unless host.blank? or host =~ %r{^[-a-z]+://} + host = "#{@controller.request.protocol}#{host}" + end - "#{host}#{source}" - else - source + "#{host}#{source}" + else + source + end + end end - end end # Pick an asset host for this source. Returns nil if no host is set, |