From f05b870ae0c664e061b54482bdb900fb6184fcda Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 10 Jan 2008 00:47:08 +0000 Subject: Fix CacheHelper#cache (closes #10733) [mindforge] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8614 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/helpers/cache_helper.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'actionpack/lib') 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 # Topics listed alphabetically # <% 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 -- cgit v1.2.3