Purpose of 'yield' in layout file in Flickr video?

During the excellent flickr video, the presenter
adds the following to the applications layout file:

<%= yield %>

What is the purpose of the ‘yield’ line? I would think
there would be a content_for_layout tag there instead.

Thanks,
Don

On 12/16/05, don mc [email protected] wrote:

What is the purpose of the ‘yield’ line? I would think
there would be a content_for_layout tag there instead.

Thanks,
Don

It has to do with the way the layouts are built. Yield is just a
shortcut. You can also do:

<%= yield :foo %> instead of @content_for_foo.


rick
http://techno-weenie.net

Hi Don,

On 12/16/05, don mc [email protected] wrote:

What is the purpose of the ‘yield’ line? I would think
there would be a content_for_layout tag there instead.

You can say <%= yield %> instead of <%= @content_for_layout %> and,
e.g., <%= yield :sidebar %> instead of <%= @content_for_sidebar %>.

Here’s the relevant magic:
http://dev.rubyonrails.org/browser/trunk/actionpack/lib/action_view/base.rb?rev=3314#L292


sam

Sam S. wrote:

Hi Don,

On 12/16/05, don mc [email protected] wrote:

What is the purpose of the ‘yield’ line? I would think
there would be a content_for_layout tag there instead.

You can say <%= yield %> instead of <%= @content_for_layout %> and,
e.g., <%= yield :sidebar %> instead of <%= @content_for_sidebar %>.

Here’s the relevant magic:
http://dev.rubyonrails.org/browser/trunk/actionpack/lib/action_view/base.rb?rev=3314#L292


sam

Thanks all for the quick response!
Don