Skip to content

Commit

Permalink
Streamline fragment_for SafeBuffer logic to make it more concise and …
Browse files Browse the repository at this point in the history
…robust against unsafe buffers.
  • Loading branch information
cmeiklejohn committed Jun 20, 2011
1 parent f542188 commit 03d01ec
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions actionpack/lib/action_view/helpers/cache_helper.rb
Expand Up @@ -51,12 +51,10 @@ def fragment_for(name = {}, options = nil, &block) #:nodoc:
# This dance is needed because Builder can't use capture
pos = output_buffer.length
yield
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)
output_safe = output_buffer.html_safe?
fragment = output_buffer.slice!(pos..-1)
if output_safe
self.output_buffer = output_buffer.html_safe
end
controller.write_fragment(name, fragment, options)
end
Expand Down

0 comments on commit 03d01ec

Please sign in to comment.