aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorRodrigo Rosenfeld Rosas <rr_rosas@yahoo.com.br>2009-02-22 12:13:25 -0300
committerRodrigo Rosenfeld Rosas <rr_rosas@yahoo.com.br>2009-02-22 12:18:35 -0300
commit966f86402a43a481491f85ac0e55f820ed831583 (patch)
tree25358b43201ccd393ac0ad387d89352324e060e3 /railties
parent247b9563ac81f6e66bc3c5af8e280adad66258a4 (diff)
downloadrails-966f86402a43a481491f85ac0e55f820ed831583.tar.gz
rails-966f86402a43a481491f85ac0e55f820ed831583.tar.bz2
rails-966f86402a43a481491f85ac0e55f820ed831583.zip
Corrects information about subtemplates.
The note about incompatibilities between 2.2 and 2.3 was removed because on Rails 2.2.2, "render :file => 'layouts/application'" works.
Diffstat (limited to 'railties')
-rw-r--r--railties/guides/source/layouts_and_rendering.textile16
1 files changed, 7 insertions, 9 deletions
diff --git a/railties/guides/source/layouts_and_rendering.textile b/railties/guides/source/layouts_and_rendering.textile
index 3d27b52e41..d9bc605b84 100644
--- a/railties/guides/source/layouts_and_rendering.textile
+++ b/railties/guides/source/layouts_and_rendering.textile
@@ -920,14 +920,14 @@ Suppose you have the follow +ApplicationController+ layout:
<erb>
<html>
<head>
- <title><%= @page_title %><title>
- <% stylesheet_tag 'layout' %>
+ <title><%= @page_title or 'Page Title' %></title>
+ <%= stylesheet_link_tag 'layout' %>
<style type="text/css"><%= yield :stylesheets %></style>
-<head>
+</head>
<body>
<div id="top_menu">Top menu items here</div>
<div id="menu">Menu items here</div>
- <div id="main"><%= yield %></div>
+ <div id="content"><%= yield(:content) or yield %></div>
</body>
</html>
</erb>
@@ -941,18 +941,16 @@ On pages generated by +NewsController+, you want to hide the top menu and add a
#top_menu {display: none}
#right_menu {float: right; background-color: yellow; color: black}
<% end -%>
-<% content_for :main %>
+<% content_for :content do %>
<div id="right_menu">Right menu items here</div>
- <%= yield %>
+ <%= yield(:news_content) or yield %>
<% end -%>
<% render :file => 'layouts/application' %>
</erb>
-NOTE: In versions of Rails before Rails 2.3, you should use +render 'layouts/applications'+ instead of +render :file => 'layouts/applications'+
-
That's it. The News views will use the new layout, hiding the top menu and adding a new right menu inside the "content" div.
-There are several ways of getting similar results with different sub-templating schemes using this technique. Note that there is no limit in nesting levels. One can use the +ActionView::render+ method via +render 'layouts/news'+ to base a new layout on the News layout.
+There are several ways of getting similar results with different sub-templating schemes using this technique. Note that there is no limit in nesting levels. One can use the +ActionView::render+ method via +render :file => 'layouts/news'+ to base a new layout on the News layout. If one is sure she will not subtemplate the +News+ layout, she can ommit the +yield(:news_content) or + part.
h3. Changelog