mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Use render :template instead of render :file in nested layouts example. render :template is a bit faster and more semantic compared to render :file.
This commit is contained in:
parent
410114e85a
commit
fc8c072988
1 changed files with 2 additions and 2 deletions
|
@ -1185,12 +1185,12 @@ On pages generated by +NewsController+, you want to hide the top menu and add a
|
|||
<div id="right_menu">Right menu items here</div>
|
||||
<%= yield(:news_content) or yield %>
|
||||
<% end %>
|
||||
<%= render :file => 'layouts/application' %>
|
||||
<%= 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 :file => '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 +yield(:news_content) or yield+ with simply +yield+.
|
||||
|
||||
h3. Changelog
|
||||
|
||||
|
|
Loading…
Reference in a new issue