Permalink
Browse files

Improves documentation of Capture helper [ci skip]

  • Loading branch information...
1 parent 20b40c8 commit cd026d7e8e6be66e0b73f4544d699294b81e08c6 @alvaropereyra alvaropereyra committed Dec 1, 2012
View
2 actionpack/lib/action_view/helpers/benchmark_helper.rb
@@ -2,7 +2,7 @@
module ActionView
module Helpers
- module BenchmarkHelper
+ module BenchmarkHelper #:nodoc:
include ActiveSupport::Benchmarkable
def benchmark(*)
View
25 actionpack/lib/action_view/helpers/capture_helper.rb
@@ -42,14 +42,12 @@ def capture(*args)
end
# Calling content_for stores a block of markup in an identifier for later use.
- # You can make subsequent calls to the stored content in other templates, helper modules
- # or the layout by passing the identifier as an argument to <tt>content_for</tt>.
+ # In order to access this stored content in other templates, helper modules
+ # or the layout, you would pass the identifier as an argument to <tt>content_for</tt>.
#
# Note: <tt>yield</tt> can still be used to retrieve the stored content, but calling
# <tt>yield</tt> doesn't work in helper modules, while <tt>content_for</tt> does.
#
- # ==== Examples
- #
# <% content_for :not_authorized do %>
# alert('You are not authorized to do that!')
# <% end %>
@@ -74,7 +72,8 @@ def capture(*args)
#
# <%= stored_content %>
#
- # You can use the <tt>yield</tt> syntax alongside an existing call to <tt>yield</tt> in a layout. For example:
+ # You can also use the <tt>yield</tt> syntax alongside an existing call to
+ # <tt>yield</tt> in a layout. For example:
#
# <%# This is the layout %>
# <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
@@ -106,7 +105,8 @@ def capture(*args)
# <% end %>
#
# That will place +script+ tags for your default set of JavaScript files on the page;
- # this technique is useful if you'll only be using these scripts in a few views.
+ # this technique is useful if you'll only be using these scripts in a few views, like,
+ # for example, external libs such as Google Maps.
#
# Note that content_for concatenates (default) the blocks it is given for a particular
# identifier in order. For example:
@@ -115,7 +115,7 @@ def capture(*args)
# <li><%= link_to 'Home', action: 'index' %></li>
# <% end %>
#
- # <%# Add some other content, or use a different template: %>
+ # And in other place:
#
# <% content_for :navigation do %>
# <li><%= link_to 'Login', action: 'login' %></li>
@@ -145,8 +145,8 @@ def capture(*args)
#
# <% content_for :script, javascript_include_tag(:defaults) %>
#
- # WARNING: content_for is ignored in caches. So you shouldn't use it
- # for elements that will be fragment cached.
+ # WARNING: content_for is ignored in caches since there won't be processed.
+ # So you shouldn't use it for elements that will be fragment cached.
def content_for(name, content = nil, options = {}, &block)
if content || block_given?
if block_given?
@@ -173,10 +173,9 @@ def provide(name, content = nil, &block)
result unless content
end
- # content_for? simply checks whether any content has been captured yet using content_for
- # Useful to render parts of your layout differently based on what is in your views.
- #
- # ==== Examples
+ # content_for? simply checks whether any content has already been captured
+ # yet using content_for. Useful to render parts of your layout differently
+ # based on what is in your views.
#
# Perhaps you will use different css in you layout if no content_for :right_column
#

0 comments on commit cd026d7

Please sign in to comment.