Skip to content

Commit

Permalink
Merge pull request #1787 from cmeiklejohn/make_fragment_for_more_robu…
Browse files Browse the repository at this point in the history
…st_for_subclasses_of_safe_buffer

fragment_for assumes ActionView::OutputBuffer.
  • Loading branch information
josevalim committed Jun 20, 2011
2 parents 81f7bf5 + a52e418 commit ac78ff7
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 ac78ff7

Please sign in to comment.