diff options
Diffstat (limited to 'actionpack/lib')
-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 |