- application.rhtml is the master layout that gets rendered if no
other layout is specified. inside it, you put something like this to
the place where your "subtemplate" of each controller should go in
...some HTML...
<%= yield :sublayout %>
...someHTML...
- now you have a controller named "articles", then you create a layout
"articles.rhtml" inside it you do e.g. this:
<%content_for "sublayout" do %>
<div id="sublayout">
blablabla
<%= yield %> (This puts the rendered template of the action that was
requested in here)
blablabla
<div>
<%end%>
<%= render :file "layouts/application.rhrml%> (this renders the
master
layout around it)
1) rails renders the action template (e.g. "show.rhtml"),
2) puts it inside the controller''s "articles.rhtml" layout,
which is
saved to the content_for "sublayout"
3) "application.rhtml" is rendered, and the whole
"articles.rhtml" is
oput inside it where you specified <%= yield :subtemplate %>
You may read this article about best practice for sidebars in rails,
the idea is usable for stuff like this too:
http://errtheblog.com/post/28
On 20 Feb., 14:33, "libsfan01"
<mcyi2...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
wrote:> hi all
>
> i would like to design my site so there is a master layout which is
> the same for every page or a group of pages then a layout for each
> controller, as scaffolds create, which gets embedded within the master
> layout. then finally within this layout the actual action code is
> displayed.
>
> is this possible? what is the code to embed a layout within a layout?
>
> thanks
>
> marc
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---