Content_for_layout

Question- if I have more then one view I wish to display in a layout ,
how
do I tell content_for_layout what to display and where ?

TIA
Stuart

On Thu, 13 Jul 2006, Dark A. wrote:

Question- if I have more then one view I wish to display in a layout , how
do I tell content_for_layout what to display and where ?

content_for_layout is deprecated (in favor of yield [1]), but the
principles are the same either way. Your layout should only have one
yield
in it, where the content goes.

As for the rest, have your main view render one or more partials (my
layouts typically render partials for the various pieces of the page).

[1] http://weblog.rubyonrails.com/2006/04/25/use-params-not-params/

Deirdre Saoirse M. wrote on 13.07.2006 22:42:

On Thu, 13 Jul 2006, Dark A. wrote:

Question- if I have more then one view I wish to display in a layout , how
do I tell content_for_layout what to display and where ?

content_for_layout is deprecated (in favor of yield [1]), but the

What else is deprecated? It’s really strange to say that something from
a stable release is deprecated when it isn’t marked as deprecated and
there is no replacement documented, isn’t it?

Stuart,
In your application.rhtml use <%= yield %> to display your view.
If you wish to display another portion of that view somewhere else
in the layout do this:

— [ your view ] —
my main view content…

<% content_for(“nav”) do -%>
my nav stuff
<% end -%>

— [ application.rhtml ] —
<%= yield :nav %>

Hope this helps,
Zack

On Fri, 14 Jul 2006, Markus K. wrote:

there is no replacement documented, isn’t it?
It is documented. Did you see the link I also pasted?

Yeah, I’m getting used to the sort of documentation :). It would be
better
perhaps if there was a page that listed all that is deprecated.
If I’m using IRB or Scite in a straight Ruby environment that Ruby will
tell
it’s deprecated. Not sure how that all works in Rails and where to look
for
Rails generated code feedback.

Stuart

Deirdre Saoirse M. wrote on 14.07.2006 01:16:

there is no replacement documented, isn’t it?

It is documented. Did you see the link I also pasted?

The link? That’s a comment thread about the yield stuff but no
documentation. The API of stable Rails is documentation and it says to
use content_for_layout. The API of edge has changed and it says yield.
So you have to say that content_for_layout will be deprecated in the
future but it is the supported thing for stable Rails, isn’t it?