Custom content in layout sidebars.

From: Sam P.
Sent on: Wednesday, June 20, 2007 7:44 AM
Regarding Ivan's problem - custom sidebar content in layouts, here is a solution I found on the way home:

Agile Development with Ruby on Rails, Section 22.9, Passing Data to Layouts, Page 508:

The same mechanism that lets you use
yield :layout to embed the rendering of a template into the layout also allows you to generate arbitrary content in a template, which you can then embed in any template.

For example, different templates may need to add their own template-specific items to the standard page sidebar. We'll use the
content_for mechanism in those templates to define content and then use yield in the layout to embed this content into the sidebar.


Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy