Optional layout content

11 views
Skip to first unread message

BobTodd

unread,
Dec 20, 2010, 9:49:02 AM12/20/10
to StaticMatic
Hi

Looking for advice as to the best structure for:

I have a layout that is typical - it has a header, a nav bar, then
some main content, which has two columns, a side-bar and the content.

I understand that yield would typically be placed in the main content
div.

However, that side-bar is optional for pages, and it is context
sensitive in that each page sets the content within it, although the
containing layout is the same.

How would one typically implement this optionality?

I'm visualising it as, there's a content div in the layout page, and
it has a content_for variable in it.

Each page then loads one of two partials, (one with one column or one
with two columns), writes out the page's content to (one or) two
variables in the partial and sets that as the content_for in the
layout.

Am I on the right lines?

Thanks

BobTodd

unread,
Dec 20, 2010, 10:19:02 AM12/20/10
to StaticMatic
Looks like I answered it myself

1 variable in the layout and 1 or 2 variables in 1 of 2 partials.

"capture_haml" to the rescue!

- @page_title = "About us"
- @wide_content = capture_haml do
some wide content
- @content = capture_haml do #used by layout
= partial('_no-sidebar') #uses @wide_content
Reply all
Reply to author
Forward
0 new messages