diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-01-10 00:47:08 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-01-10 00:47:08 +0000 |
commit | f05b870ae0c664e061b54482bdb900fb6184fcda (patch) | |
tree | 47a6a50902928081f8bd4677ba09b75b0e415657 /actionpack | |
parent | 4ad3721a17c721133e3a5c0e6894625a91ccee1e (diff) | |
download | rails-f05b870ae0c664e061b54482bdb900fb6184fcda.tar.gz rails-f05b870ae0c664e061b54482bdb900fb6184fcda.tar.bz2 rails-f05b870ae0c664e061b54482bdb900fb6184fcda.zip |
Fix CacheHelper#cache (closes #10733) [mindforge]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8614 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/helpers/cache_helper.rb | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/actionpack/lib/action_view/helpers/cache_helper.rb b/actionpack/lib/action_view/helpers/cache_helper.rb index eb631cf201..783a5acdbc 100644 --- a/actionpack/lib/action_view/helpers/cache_helper.rb +++ b/actionpack/lib/action_view/helpers/cache_helper.rb @@ -32,7 +32,7 @@ module ActionView # <i>Topics listed alphabetically</i> # <% end %> def cache(name = {}, options = nil, &block) - template_extension = first_render[/\.(\w+)$/, 1].to_sym + template_extension = find_template_extension_for(first_render)[/\.(\w+)$/, 1].to_sym case template_extension when :erb, :rhtml @@ -42,14 +42,13 @@ module ActionView when :builder, :rxml @controller.cache_rxml_fragment(block, name, options) else - # do a last ditch effort for those brave souls using - # different template engines. This should give plugin - # writters a simple hook. - unless @controller.respond_to?("cache_#{template_extension}_fragment") - raise "fragment caching not supported for #{template_extension} files." + # Give template engine writers a hook to implement their own caching approach + if @controller.respond_to?("cache_#{template_extension}_fragment") + @controller.send!("cache_#{template_extension}_fragment", block, name, options) + else + # Let the ERb approach be the default one if the plugin doesn't specify it's own + @controller.cache_erb_fragment(block, name, options) end - - @controller.send!("cache_#{template_extension}_fragment", block, name, options) end end end |