aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorJacob Mattingley <jem@ubalo.com>2011-08-15 16:00:53 -0700
committerJacob Mattingley <jem@ubalo.com>2011-08-15 16:00:53 -0700
commit583d7c15c301f15f1e997a06e15b55a2e7bf794f (patch)
tree38a288f866ecef1edc628ab7904f5ca5f67d3f97 /railties
parentf7626ea38ebf1a6efdd8b059204aa2d22e096f39 (diff)
downloadrails-583d7c15c301f15f1e997a06e15b55a2e7bf794f.tar.gz
rails-583d7c15c301f15f1e997a06e15b55a2e7bf794f.tar.bz2
rails-583d7c15c301f15f1e997a06e15b55a2e7bf794f.zip
Fixed mistakes in layouts/rendering guide about yield
yield(:unspecified_block) actually returns true even if :unspecified_block never exists. This means you can't use the form yield(:unspecified_block) or yield.
Diffstat (limited to 'railties')
-rw-r--r--railties/guides/source/layouts_and_rendering.textile4
1 files changed, 2 insertions, 2 deletions
diff --git a/railties/guides/source/layouts_and_rendering.textile b/railties/guides/source/layouts_and_rendering.textile
index 57485e8986..87ba8ab82d 100644
--- a/railties/guides/source/layouts_and_rendering.textile
+++ b/railties/guides/source/layouts_and_rendering.textile
@@ -1179,14 +1179,14 @@ On pages generated by +NewsController+, you want to hide the top menu and add a
<% end %>
<% content_for :content do %>
<div id="right_menu">Right menu items here</div>
- <%= yield(:news_content) or yield %>
+ <%= content_for?(:news_content) ? yield(:news_content) : yield %>
<% end %>
<%= render :template => 'layouts/application' %>
</erb>
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 :template => 'layouts/news'+ to base a new layout on the News layout. If you are sure you will not subtemplate the +News+ layout, you can replace the +yield(:news_content) or yield+ with simply +yield+.
+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 :template => 'layouts/news'+ to base a new layout on the News layout. If you are sure you will not subtemplate the +News+ layout, you can replace the +content_for?(:news_content) ? yield(:news_content) : yield+ with simply +yield+.
h3. Changelog