Using content_for in a partial with its own layout

Can anyone tell me how content_for concatenates content into the instance variable? I've been digging through ActionView code like crazy trying to find it. Here's some context:

Our system has a number of partials that render different types of posted items (image, file, video, etc) like so:

Also worth noting I am using Rails 2.3.8 not 3.