Permalink
Browse files

Move the write portion of fragment_for to its own method to allow for…

… easier creation of custom cache methods.
  • Loading branch information...
1 parent 840c552 commit f341acdae3abfa97247736dde01f5e79c61de7d2 @rovermicrover rovermicrover committed with carlosantoniodasilva Jun 1, 2013
Showing with 14 additions and 10 deletions.
  1. +14 −10 actionview/lib/action_view/helpers/cache_helper.rb
@@ -179,17 +179,21 @@ def fragment_for(name = {}, options = nil, &block) #:nodoc:
if fragment = controller.read_fragment(name, options)
fragment
else
- # VIEW TODO: Make #capture usable outside of ERB
- # This dance is needed because Builder can't use capture
- pos = output_buffer.length
- yield
- output_safe = output_buffer.html_safe?
- fragment = output_buffer.slice!(pos..-1)
- if output_safe
- self.output_buffer = output_buffer.class.new(output_buffer)
- end
- controller.write_fragment(name, fragment, options)
+ write_fragment_for(name, options, &block)
+ end
+ end
+
+ def write_fragment_for(name = {}, options = nil, &block) #:nodoc:
+ # VIEW TODO: Make #capture usable outside of ERB
+ # This dance is needed because Builder can't use capture
+ pos = output_buffer.length
+ yield
+ output_safe = output_buffer.html_safe?
+ fragment = output_buffer.slice!(pos..-1)
+ if output_safe
+ self.output_buffer = output_buffer.class.new(output_buffer)
end
+ controller.write_fragment(name, fragment, options)
end
end
end

0 comments on commit f341acd

Please sign in to comment.