From cd026d7e8e6be66e0b73f4544d699294b81e08c6 Mon Sep 17 00:00:00 2001 From: Alvaro Pereyra Date: Sat, 1 Dec 2012 13:17:04 -0500 Subject: Improves documentation of Capture helper [ci skip] --- .../lib/action_view/helpers/benchmark_helper.rb | 2 +- .../lib/action_view/helpers/capture_helper.rb | 25 +++++++++++----------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/actionpack/lib/action_view/helpers/benchmark_helper.rb b/actionpack/lib/action_view/helpers/benchmark_helper.rb index dfdd5a786d..87fbf8f1a8 100644 --- a/actionpack/lib/action_view/helpers/benchmark_helper.rb +++ b/actionpack/lib/action_view/helpers/benchmark_helper.rb @@ -2,7 +2,7 @@ require 'active_support/benchmarkable' module ActionView module Helpers - module BenchmarkHelper + module BenchmarkHelper #:nodoc: include ActiveSupport::Benchmarkable def benchmark(*) diff --git a/actionpack/lib/action_view/helpers/capture_helper.rb b/actionpack/lib/action_view/helpers/capture_helper.rb index 85e398e559..d7fc3d5c4b 100644 --- a/actionpack/lib/action_view/helpers/capture_helper.rb +++ b/actionpack/lib/action_view/helpers/capture_helper.rb @@ -42,14 +42,12 @@ module ActionView 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 content_for. + # In order to access this stored content in other templates, helper modules + # or the layout, you would pass the identifier as an argument to content_for. # # Note: yield can still be used to retrieve the stored content, but calling # yield doesn't work in helper modules, while content_for does. # - # ==== Examples - # # <% content_for :not_authorized do %> # alert('You are not authorized to do that!') # <% end %> @@ -74,7 +72,8 @@ module ActionView # # <%= stored_content %> # - # You can use the yield syntax alongside an existing call to yield in a layout. For example: + # You can also use the yield syntax alongside an existing call to + # yield in a layout. For example: # # <%# This is the layout %> # @@ -106,7 +105,8 @@ module ActionView # <% 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 @@ module ActionView #
  • <%= link_to 'Home', action: 'index' %>
  • # <% end %> # - # <%# Add some other content, or use a different template: %> + # And in other place: # # <% content_for :navigation do %> #
  • <%= link_to 'Login', action: 'login' %>
  • @@ -145,8 +145,8 @@ module ActionView # # <% 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 @@ module ActionView 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 # -- cgit v1.2.3