aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/cache_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_view/helpers/cache_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/cache_helper.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/helpers/cache_helper.rb b/actionpack/lib/action_view/helpers/cache_helper.rb
index 87a8e8dc98..eb631cf201 100644
--- a/actionpack/lib/action_view/helpers/cache_helper.rb
+++ b/actionpack/lib/action_view/helpers/cache_helper.rb
@@ -31,21 +31,25 @@ module ActionView
# <%= render :partial => "topics", :collection => @topic_list %>
# <i>Topics listed alphabetically</i>
# <% end %>
- def cache(name = {}, &block)
+ def cache(name = {}, options = nil, &block)
template_extension = first_render[/\.(\w+)$/, 1].to_sym
+
case template_extension
when :erb, :rhtml
- @controller.cache_erb_fragment(block, name)
+ @controller.cache_erb_fragment(block, name, options)
when :rjs
- @controller.cache_rjs_fragment(block, name)
+ @controller.cache_rjs_fragment(block, name, options)
when :builder, :rxml
- @controller.cache_rxml_fragment(block, name)
+ @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.
- 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
+ unless @controller.respond_to?("cache_#{template_extension}_fragment")
+ raise "fragment caching not supported for #{template_extension} files."
+ end
+
+ @controller.send!("cache_#{template_extension}_fragment", block, name, options)
end
end
end