mirror of https://github.com/rails/rails
Several fixes for AV::Helpers::CaptureHelper
This commit is contained in:
parent
2978f8dd05
commit
f7c0b38dd4
|
@ -5,16 +5,19 @@ require "active_support/core_ext/string/output_safety"
|
||||||
module ActionView
|
module ActionView
|
||||||
# = Action View Capture Helper
|
# = Action View Capture Helper
|
||||||
module Helpers # :nodoc:
|
module Helpers # :nodoc:
|
||||||
# CaptureHelper exposes methods to let you extract generated markup which
|
# \CaptureHelper exposes methods to let you extract generated markup which
|
||||||
# can be used in other parts of a template or layout file.
|
# can be used in other parts of a template or layout file.
|
||||||
#
|
#
|
||||||
# It provides a method to capture blocks into variables through capture and
|
# It provides a method to capture blocks into variables through #capture and
|
||||||
# a way to capture a block of markup for use in a layout through {content_for}[rdoc-ref:ActionView::Helpers::CaptureHelper#content_for].
|
# a way to capture a block of markup for use in a layout through #content_for.
|
||||||
|
#
|
||||||
|
# As well as provides a method when using streaming responses through #provide.
|
||||||
|
# See ActionController::Streaming for more information.
|
||||||
module CaptureHelper
|
module CaptureHelper
|
||||||
# The capture method extracts part of a template as a String object.
|
# The capture method extracts part of a template as a string object.
|
||||||
# You can then use this object anywhere in your templates, layout, or helpers.
|
# You can then use this object anywhere in your templates, layout, or helpers.
|
||||||
#
|
#
|
||||||
# The capture method can be used in ERB templates...
|
# The capture method can be used in \ERB templates...
|
||||||
#
|
#
|
||||||
# <% @greeting = capture do %>
|
# <% @greeting = capture do %>
|
||||||
# Welcome to my shiny new web page! The date and time is
|
# Welcome to my shiny new web page! The date and time is
|
||||||
|
@ -178,6 +181,8 @@ module ActionView
|
||||||
# concatenate several times to the same buffer when rendering a given
|
# concatenate several times to the same buffer when rendering a given
|
||||||
# template, you should use +content_for+, if not, use +provide+ to tell
|
# template, you should use +content_for+, if not, use +provide+ to tell
|
||||||
# the layout to stop looking for more contents.
|
# the layout to stop looking for more contents.
|
||||||
|
#
|
||||||
|
# See ActionController::Streaming for more information.
|
||||||
def provide(name, content = nil, &block)
|
def provide(name, content = nil, &block)
|
||||||
content = capture(&block) if block_given?
|
content = capture(&block) if block_given?
|
||||||
result = @view_flow.append!(name, content) if content
|
result = @view_flow.append!(name, content) if content
|
||||||
|
@ -185,6 +190,7 @@ module ActionView
|
||||||
end
|
end
|
||||||
|
|
||||||
# <tt>content_for?</tt> checks whether any content has been captured yet using <tt>content_for</tt>.
|
# <tt>content_for?</tt> checks whether any content has been captured yet using <tt>content_for</tt>.
|
||||||
|
#
|
||||||
# Useful to render parts of your layout differently based on what is in your views.
|
# Useful to render parts of your layout differently based on what is in your views.
|
||||||
#
|
#
|
||||||
# <%# This is the layout %>
|
# <%# This is the layout %>
|
||||||
|
|
Loading…
Reference in New Issue