From f7c0b38dd4027d74b5ccfdd237c2ccf3fcd89e75 Mon Sep 17 00:00:00 2001 From: zzak Date: Sun, 29 Jan 2023 09:54:11 +0900 Subject: [PATCH] Several fixes for AV::Helpers::CaptureHelper --- .../lib/action_view/helpers/capture_helper.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/actionview/lib/action_view/helpers/capture_helper.rb b/actionview/lib/action_view/helpers/capture_helper.rb index 54bf1b3c942..4d9317d28ac 100644 --- a/actionview/lib/action_view/helpers/capture_helper.rb +++ b/actionview/lib/action_view/helpers/capture_helper.rb @@ -5,16 +5,19 @@ require "active_support/core_ext/string/output_safety" module ActionView # = Action View Capture Helper 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. # - # 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]. + # 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. + # + # As well as provides a method when using streaming responses through #provide. + # See ActionController::Streaming for more information. 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. # - # The capture method can be used in ERB templates... + # The capture method can be used in \ERB templates... # # <% @greeting = capture do %> # 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 # template, you should use +content_for+, if not, use +provide+ to tell # the layout to stop looking for more contents. + # + # See ActionController::Streaming for more information. def provide(name, content = nil, &block) content = capture(&block) if block_given? result = @view_flow.append!(name, content) if content @@ -185,6 +190,7 @@ module ActionView end # content_for? 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. # # <%# This is the layout %>