During the excellent flickr video, the presenter adds the following to the applications layout file: <body> <%= yield %> </body> What is the purpose of the ''yield'' line? I would think there would be a content_for_layout tag there instead. Thanks, Don -- Posted via http://www.ruby-forum.com/.
On 12/16/05, don mc <don.mcclean-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> During the excellent flickr video, the presenter > adds the following to the applications layout file: > > > <body> > <%= yield %> > </body> > > > > What is the purpose of the ''yield'' line? I would think > there would be a content_for_layout tag there instead. > > Thanks, > DonIt 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
Sam Stephenson
2005-Dec-16 17:21 UTC
Re: Purpose of ''yield'' in layout file in Flickr video?
Hi Don, On 12/16/05, don mc <don.mcclean-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> During the excellent flickr video, the presenter > adds the following to the applications layout file: > > > <body> > <%= yield %> > </body> > > > > 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 Stephenson wrote:> Hi Don, > > On 12/16/05, don mc <don.mcclean-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 > > -- > samThanks all for the quick response! Don -- Posted via http://www.ruby-forum.com/.