From 966f86402a43a481491f85ac0e55f820ed831583 Mon Sep 17 00:00:00 2001 From: Rodrigo Rosenfeld Rosas Date: Sun, 22 Feb 2009 12:13:25 -0300 Subject: 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. --- railties/guides/source/layouts_and_rendering.textile | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'railties') 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: - <%= @page_title %><title> - <% stylesheet_tag 'layout' %> + <title><%= @page_title or 'Page Title' %> + <%= stylesheet_link_tag 'layout' %> - +
Top menu items here
-
<%= yield %>
+
<%= yield(:content) or yield %>
@@ -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 %>
Right menu items here
- <%= yield %> + <%= yield(:news_content) or yield %> <% end -%> <% render :file => 'layouts/application' %> -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 -- cgit v1.2.3