Permalink
Browse files

Adapt [823aa22] to make sure we perform cloning before manipulation o…

…nly on `OutputBuffer`.

After the fragment rendering, `Builder` returns the `String` object instead of `ActionView::OutputBuffer`. Somehow the same procedure which was in [823aa22] does not play nice with the String, and result in the fragment got lost.
  • Loading branch information...
1 parent 1d3618a commit 07f2481e152502050f23834596efc76f4a208fc3 @sikachu sikachu committed Jun 8, 2011
Showing with 7 additions and 3 deletions.
  1. +7 −3 actionpack/lib/action_view/helpers/cache_helper.rb
@@ -51,9 +51,13 @@ def fragment_for(name = {}, options = nil, &block) #:nodoc:
# This dance is needed because Builder can't use capture
pos = output_buffer.length
yield
- safe_output_buffer = output_buffer.to_str
- fragment = safe_output_buffer.slice!(pos..-1)
- self.output_buffer = ActionView::OutputBuffer.new(safe_output_buffer)
+ if output_buffer.is_a?(ActionView::OutputBuffer)
+ safe_output_buffer = output_buffer.to_str
+ fragment = safe_output_buffer.slice!(pos..-1)
+ self.output_buffer = ActionView::OutputBuffer.new(safe_output_buffer)
+ else
+ fragment = output_buffer.slice!(pos..-1)
+ end
controller.write_fragment(name, fragment, options)
end
end

0 comments on commit 07f2481

Please sign in to comment.