On Mon, May 22, 2006 at 07:45:43PM -0700, Sam D. wrote:
Hi,
I want to be able to have several layouts within each other so that I don’t
have to keep repeating the layout code for one, in another. An example
would be having a layout for the title of your web page and then having an
embedded layout for the body portion in which the HTML for whatever view
gets displayed. Is this possible?
I ran into this badly in a project that is almost finished. I have 5
major sections to the site, each with a submenu above the content which
is shared for that section, save for the “current” page being
highlighted.
What I need is two layouts. The main layout would be:
...
...
...
<%= @content_for_layout %>
...
But @content_for_layout would be the output of another layout:
...
<%= @content_for_layout %>
That way, each section could get its own submenu layout file, and
nothing would be repeated.
As it is right now, I have repeated the submenu code in all of the
views for a particular section, which is hideous.
My other option is to create a separate layout for each one, but then
the rest of the page code would be repeated.
And the last option is to create two partials for each section: a
“header” and a “footer”. Then I could render those in every view.
That’s ugly, though, as the code would be split up.
I need to be able to nest layouts, and I believe this would be a very
useful feature. I just don’t have the internals experience to pull it
off.
Any ideas?
Thanks,
Michael
Michael Darrin Chaney
[email protected]
http://www.michaelchaney.com/