Forum: Ruby on Rails RE: 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 03:09
(Received via mailing list)
Just found the answer to my post.

If somebody else is looking for an answer to a similar question:

In Rails, layouts have access to all the same data that is available to
conventional templates. Any instance variables set in the normal
template will be available in the layout.

Following my previous example you could do this:

My template file t1.rhtml:

<div>
	Some content
	<% @show_menu = "true" %>
</div>

And this is the layout1.rhtml (layout file that t1 gets decorated with):
<html>
<head></head>
<body>
<%if @show_menu == "true"%>
<div id='menu'></div>
<%end%>
<div id='main'> <%=@content_for_layout%> </div> </body> </html>
This topic is locked and can not be replied to.