diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-01-03 15:35:10 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-01-03 15:35:10 +0000 |
commit | e2e98ef0b8a575712707e4297c5206e2ed7a7d90 (patch) | |
tree | c94755dbacc4a1e693587800f87b535efc2c8e65 /actionpack/lib/action_view | |
parent | d5645fd4a0b8160646e69273626a77badd9ab1a4 (diff) | |
download | rails-e2e98ef0b8a575712707e4297c5206e2ed7a7d90.tar.gz rails-e2e98ef0b8a575712707e4297c5206e2ed7a7d90.tar.bz2 rails-e2e98ef0b8a575712707e4297c5206e2ed7a7d90.zip |
Made fragment caching in views work for rjs and builder as well (closes #6642) [zsombor]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8542 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/cache_helper.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/cache_helper.rb b/actionpack/lib/action_view/helpers/cache_helper.rb index cf5420a35e..87a8e8dc98 100644 --- a/actionpack/lib/action_view/helpers/cache_helper.rb +++ b/actionpack/lib/action_view/helpers/cache_helper.rb @@ -32,7 +32,21 @@ module ActionView # <i>Topics listed alphabetically</i> # <% end %> def cache(name = {}, &block) - @controller.cache_erb_fragment(block, name) + template_extension = first_render[/\.(\w+)$/, 1].to_sym + case template_extension + when :erb, :rhtml + @controller.cache_erb_fragment(block, name) + when :rjs + @controller.cache_rjs_fragment(block, name) + when :builder, :rxml + @controller.cache_rxml_fragment(block, name) + else + # do a last ditch effort for those brave souls using + # different template engines. This should give plugin + # writters a simple hook. + raise "fragment caching not supported for #{template_extension} files." unless @controller.respond_to?("cache_#{template_extension}_fragment") + @controller.send "cache_#{template_extension}_fragment", block, name + end end end end |