Permalink
Browse files

Fix CacheHelper#cache (closes #10733) [mindforge]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8614 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
dhh committed Jan 10, 2008
1 parent 4ad3721 commit f05b870ae0c664e061b54482bdb900fb6184fcda
Showing with 7 additions and 8 deletions.
  1. +7 −8 actionpack/lib/action_view/helpers/cache_helper.rb
@@ -32,7 +32,7 @@ module CacheHelper
# <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 @@ def cache(name = {}, options = nil, &block)
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

0 comments on commit f05b870

Please sign in to comment.