diff options
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/layout.rb | 12 | ||||
-rw-r--r-- | actionpack/lib/action_controller/templates/scaffolds/layout.rhtml | 2 |
2 files changed, 8 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/layout.rb b/actionpack/lib/action_controller/layout.rb index 7ecff73380..4e9e42d468 100644 --- a/actionpack/lib/action_controller/layout.rb +++ b/actionpack/lib/action_controller/layout.rb @@ -27,7 +27,7 @@ module ActionController #:nodoc: # that the header and footer are only mentioned in one place, like this: # # <!-- The header part of this layout --> - # <%= @content_for_layout %> + # <%= yield %> # <!-- The footer part of this layout --> # # And then you have content pages that look like this: @@ -47,7 +47,7 @@ module ActionController #:nodoc: # references that won't materialize before rendering time: # # <h1><%= @page_title %></h1> - # <%= @content_for_layout %> + # <%= yield %> # # ...and content pages that fulfill these references _at_ rendering time: # @@ -159,10 +159,12 @@ module ActionController #:nodoc: # # As you can see, you pass the template as the first parameter, the status code as the second ("200" is OK), and the layout # as the third. + # + # NOTE: The old notation for rendering the view from a layout was to expose the magic <tt>@content_for_layout</tt> instance + # variable. The preferred notation now is to use <tt>yield</tt>, as documented above. module ClassMethods - # If a layout is specified, all actions rendered through render and render_action will have their result assigned - # to <tt>@content_for_layout</tt>, which can then be used by the layout to insert their contents with - # <tt><%= @content_for_layout %></tt>. This layout can itself depend on instance variables assigned during action + # If a layout is specified, all rendered actions will have their result rendered + # when the layout<tt>yield</tt>'s. This layout can itself depend on instance variables assigned during action # performance and have access to them as any normal template would. def layout(template_name, conditions = {}) add_layout_conditions(conditions) diff --git a/actionpack/lib/action_controller/templates/scaffolds/layout.rhtml b/actionpack/lib/action_controller/templates/scaffolds/layout.rhtml index 120f0cfb62..759781e0e7 100644 --- a/actionpack/lib/action_controller/templates/scaffolds/layout.rhtml +++ b/actionpack/lib/action_controller/templates/scaffolds/layout.rhtml @@ -63,7 +63,7 @@ <p style="color: green"><%= flash[:notice] %></p> -<%= @content_for_layout %> +<%= yield %> </body> </html> |