diff options
author | Richard Schneeman <richard.schneeman+no-recruiters@gmail.com> | 2018-09-06 17:55:16 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-06 17:55:16 -0400 |
commit | 7fc545365cd219164e361b8e12b0995ca339477e (patch) | |
tree | 4d78b123d5058bcc8d4917ac6cf65202da59f89c | |
parent | 3e46cf75330bf103dd82eedf3c892de75290dda5 (diff) | |
parent | 31cfd5e4fdd0017f101af8f2f3d6b52b6ea68c08 (diff) | |
download | rails-7fc545365cd219164e361b8e12b0995ca339477e.tar.gz rails-7fc545365cd219164e361b8e12b0995ca339477e.tar.bz2 rails-7fc545365cd219164e361b8e12b0995ca339477e.zip |
Merge pull request #33810 from schneems/schneems/doc-output-buffer
Document ActionView::OutputBuffer
-rw-r--r-- | actionview/lib/action_view/buffers.rb | 15 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/capture_helper.rb | 4 |
2 files changed, 19 insertions, 0 deletions
diff --git a/actionview/lib/action_view/buffers.rb b/actionview/lib/action_view/buffers.rb index 2a378fdc3c..18eaee5d79 100644 --- a/actionview/lib/action_view/buffers.rb +++ b/actionview/lib/action_view/buffers.rb @@ -3,6 +3,21 @@ require "active_support/core_ext/string/output_safety" module ActionView + # Used as a buffer for views + # + # The main difference between this and ActiveSupport::SafeBuffer + # is for the methods `<<` and `safe_expr_append=` the inputs are + # checked for nil before they are assigned and `to_s` is called on + # the input. For example: + # + # obuf = ActionView::OutputBuffer.new "hello" + # obuf << 5 + # puts obuf # => "hello5" + # + # sbuf = ActiveSupport::SafeBuffer.new "hello" + # sbuf << 5 + # puts sbuf # => "hello\u0005" + # class OutputBuffer < ActiveSupport::SafeBuffer #:nodoc: def initialize(*) super diff --git a/actionview/lib/action_view/helpers/capture_helper.rb b/actionview/lib/action_view/helpers/capture_helper.rb index 92f7ddb70d..c87c212cc7 100644 --- a/actionview/lib/action_view/helpers/capture_helper.rb +++ b/actionview/lib/action_view/helpers/capture_helper.rb @@ -36,6 +36,10 @@ module ActionView # </body> # </html> # + # The return of capture is the string generated by the block. For Example: + # + # @greeting # => "Welcome to my shiny new web page! The date and time is 2018-09-06 11:09:16 -0500" + # def capture(*args) value = nil buffer = with_output_buffer { value = yield(*args) } |