Forum: Ruby on Rails Layout Question .. (Sitemesh related)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Mufaddal K. (Guest)
on 2006-04-01 01:47
(Received via mailing list)
Hi,

I understand that the layout concept is very similar to OpenSymphony's
Sitemesh project. I have done a lot of development with Sitemesh, but am
fairly new to Rails. I am wondering if there is a way for a layout in
rails to find out value of a variable from a page it is decorating?

In sitemesh you would be able to do <meta name="show_menu"
content="true"> on some page being decorated and then in the layout
page, you can access the value of show_menu using page.getProperty(..)
and can show or hide the menu.

Is there a way to do something like the above in Rails?
For example a template t1.rhtml could be:
<div>
	Some content
      <!-- can I set a variable show_menu here -->
</div>

And this is the layout1.rhtml (layout file that t1 gets decorated with):
<html>
<head></head>
<body>
<!-- can I use the variable show_menu here that might be defined in the
template this file is decorating -->
<div id='menu'></div>
<div id='main'>
<%=@content_for_layout%>
</div>
</body>
</html>

Is this possible in rails? If yes, how?

Thanks,
Mufaddal.
This topic is locked and can not be replied to.