diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/metal/helpers.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/record_identifier.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/base.rb | 3 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 14 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/form_tag_helper.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/render/layouts.rb | 48 |
6 files changed, 43 insertions, 28 deletions
diff --git a/actionpack/lib/action_controller/metal/helpers.rb b/actionpack/lib/action_controller/metal/helpers.rb index 8efe01e37b..82bedc3fad 100644 --- a/actionpack/lib/action_controller/metal/helpers.rb +++ b/actionpack/lib/action_controller/metal/helpers.rb @@ -36,7 +36,7 @@ module ActionController # # <% @events.each do |event| -%> # <p> - # <% format_time(event.time, :short, "N/A") %> | <%= event.name %> + # <%= format_time(event.time, :short, "N/A") %> | <%= event.name %> # </p> # <% end -%> # diff --git a/actionpack/lib/action_controller/record_identifier.rb b/actionpack/lib/action_controller/record_identifier.rb index fe2f6cee70..907c369218 100644 --- a/actionpack/lib/action_controller/record_identifier.rb +++ b/actionpack/lib/action_controller/record_identifier.rb @@ -9,7 +9,7 @@ module ActionController # resources :posts # # # view - # <% div_for(post) do %> <div id="post_45" class="post"> + # <%= div_for(post) do %> <div id="post_45" class="post"> # <%= post.body %> What a wonderful world! # <% end %> </div> # diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index fde61e9df9..be9791505e 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -24,9 +24,10 @@ module ActionView #:nodoc: # The loop is setup in regular embedding tags <% %> and the name is written using the output embedding tag <%= %>. Note that this # is not just a usage suggestion. Regular output functions like print or puts won't work with ERb templates. So this would be wrong: # + # <%# WRONG %> # Hi, Mr. <% puts "Frodo" %> # - # If you absolutely must write from within a function, you can use the TextHelper#concat. + # If you absolutely must write from within a function use +concat+. # # <%- and -%> suppress leading and trailing whitespace, including the trailing newline, and can be used interchangeably with <% and %>. # diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 932711f9de..fc02d959d4 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -29,7 +29,7 @@ module ActionView # # # Note: a @person variable will have been created in the controller. # # For example: @person = Person.new - # <%= form_for :person, @person, :url => { :action => "create" } do |f| %> + # <%= form_for @person do |f| %> # <%= f.text_field :first_name %> # <%= f.text_field :last_name %> # <%= submit_tag 'Create' %> @@ -45,7 +45,7 @@ module ActionView # # If you are using a partial for your form fields, you can use this shortcut: # - # <%= form_for :person, @person, :url => { :action => "create" } do |f| %> + # <%= form_for :person, @person do |form| %> # <%= render :partial => f %> # <%= submit_tag 'Create' %> # <% end %> @@ -121,7 +121,7 @@ module ActionView # The generic way to call +form_for+ yields a form builder around a # model: # - # <%= form_for :person, :url => { :action => "create" } do |f| %> + # <%= form_for :person do |f| %> # <%= f.error_messages %> # First name: <%= f.text_field :first_name %><br /> # Last name : <%= f.text_field :last_name %><br /> @@ -145,7 +145,7 @@ module ActionView # If the instance variable is not <tt>@person</tt> you can pass the actual # record as the second argument: # - # <%= form_for :person, person, :url => { :action => "create" } do |f| %> + # <%= form_for :person, person do |f| %> # ... # <% end %> # @@ -177,7 +177,7 @@ module ActionView # possible to use both the stand-alone FormHelper methods and methods # from FormTagHelper. For example: # - # <%= form_for :person, @person, :url => { :action => "create" } do |f| %> + # <%= form_for :person, @person do |f| %> # First name: <%= f.text_field :first_name %> # Last name : <%= f.text_field :last_name %> # Biography : <%= text_area :person, :biography %> @@ -359,13 +359,13 @@ module ActionView # ...or if you have an object that needs to be represented as a different # parameter, like a Client that acts as a Person: # - # <%= fields_for :person, @client, :url => { :action => "create" } do |permission_fields| %> + # <%= fields_for :person, @client do |permission_fields| %> # Admin?: <%= permission_fields.check_box :admin %> # <% end %> # # ...or if you don't have an object, just a name of the parameter: # - # <%= fields_for :person, :url => { :action => "create" } do |permission_fields| %> + # <%= fields_for :person do |permission_fields| %> # Admin?: <%= permission_fields.check_box :admin %> # <% end %> # diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 10660ecec1..081c317e0c 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -183,7 +183,7 @@ module ActionView # Creates a file upload field. If you are using file uploads then you will also need # to set the multipart option for the form tag: # - # <% form_tag '/upload', :multipart => true do %> + # <%= form_tag '/upload', :multipart => true do %> # <label for="file">File to Upload</label> <%= file_field_tag "file" %> # <%= submit_tag %> # <% end %> 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 + # <tt>yield :some_name</tt>, the block, by default, returns <tt>content_for(:some_name)</tt>. + # If the user calls simply +yield+, the default block returns <tt>content_for(:layout)</tt>. # - # ==== 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 - # <html><% yield %></html> + # <html> + # <%= yield %> + # </html> # - # 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 <html>Content</html>. + # In this case, instead of the default block, which would return <tt>content_for(:layout)</tt>, + # this method returns the block that was passed in to <tt>render :layout</tt>, and the response + # would be # - # Finally, the block can take block arguments, which can be passed in by yield. + # <html> + # Content + # </html> # - # ==== 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 - # <html><% yield Struct.new(:name).new("David") %></html> + # <html> + # <%= yield Struct.new(:name).new("David") %> + # </html> # # In this case, the layout would receive the block passed into <tt>render :layout</tt>, - # and the Struct specified in the layout would be passed into the block. The result - # would be <html>Hello David</html>. + # and the struct specified would be passed into the block as an argument. The result + # would be + # + # <html> + # Hello David + # </html> + # def _layout_for(name = nil, &block) #:nodoc: if !block || name @_content_for[name || :layout] |