Skip to content

Commit

Permalink
Updating content_for for rails 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
benhutton committed Nov 11, 2010
1 parent 6f77673 commit 60053b8
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/interlock/action_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,14 @@ module CaptureHelper
# Override content_for so we can cache the instance variables it sets along with the fragment.
#
def content_for(name, content = nil, &block)
ivar = "@content_for_#{name}"
existing_content = instance_variable_get(ivar).to_s
this_content = (block_given? ? capture(&block) : content)

content = capture(&block) if block_given?
@_content_for[name] << content if content
# If we are in a view_cache block, cache what we added to this instance variable
if @cached_content_for
@cached_content_for[name] = "#{@cached_content_for[name]}#{this_content}"
end

instance_variable_set(ivar, existing_content + this_content)
end
@_content_for[name] unless content
end
end

end
Expand Down

0 comments on commit 60053b8

Please sign in to comment.