From 43d02dffcbd6d3defea7c37892e4d47bbc061bc5 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 5 Apr 2010 02:16:24 -0700 Subject: <% yield to <%= yield in rdoc of _layout_for, and copy-edits it now that we are on it --- actionpack/lib/action_view/render/layouts.rb | 48 ++++++++++++++++++---------- 1 file changed, 31 insertions(+), 17 deletions(-) (limited to 'actionpack/lib/action_view/render') diff --git a/actionpack/lib/action_view/render/layouts.rb b/actionpack/lib/action_view/render/layouts.rb index 578f39d817..7311730a19 100644 --- a/actionpack/lib/action_view/render/layouts.rb +++ b/actionpack/lib/action_view/render/layouts.rb @@ -1,37 +1,51 @@ module ActionView module Layouts - # You can think of a layout as a method that is called with a block. _layout_for - # returns the contents that are yielded to the layout. If the user calls yield - # :some_name, the block, by default, returns content_for(:some_name). If the user - # calls yield, the default block returns content_for(:layout). + # Returns the contents that are yielded to a layout, given a name or a block. # - # The user can override this default by passing a block to the layout. + # You can think of a layout as a method that is called with a block. If the user calls + # yield :some_name, the block, by default, returns content_for(:some_name). + # If the user calls simply +yield+, the default block returns content_for(:layout). # - # ==== Example + # The user can override this default by passing a block to the layout: # # # The template - # <%= render :layout => "my_layout" do %>Content<% end %> + # <%= render :layout => "my_layout" do %> + # Content + # <% end %> # # # The layout - # <% yield %> + # + # <%= yield %> + # # - # In this case, instead of the default block, which would return content_for(:layout), - # this method returns the block that was passed in to render layout, and the response - # would be Content. + # In this case, instead of the default block, which would return content_for(:layout), + # this method returns the block that was passed in to render :layout, and the response + # would be # - # Finally, the block can take block arguments, which can be passed in by yield. + # + # Content + # # - # ==== Example + # Finally, the block can take block arguments, which can be passed in by +yield+: # # # The template - # <%= render :layout => "my_layout" do |customer| %>Hello <%= customer.name %><% end %> + # <%= render :layout => "my_layout" do |customer| %> + # Hello <%= customer.name %> + # <% end %> # # # The layout - # <% yield Struct.new(:name).new("David") %> + # + # <%= yield Struct.new(:name).new("David") %> + # # # In this case, the layout would receive the block passed into render :layout, - # and the Struct specified in the layout would be passed into the block. The result - # would be Hello David. + # and the struct specified would be passed into the block as an argument. The result + # would be + # + # + # Hello David + # + # def _layout_for(name = nil, &block) #:nodoc: if !block || name @_content_for[name || :layout] -- cgit v1.2.3