diff options
author | José Valim <jose.valim@gmail.com> | 2011-04-16 10:28:47 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-04-16 10:28:47 +0200 |
commit | e30ca001efa861cc13259ca8287837174b24e679 (patch) | |
tree | ab47ef08d8c2e8773bb7fc6d6d24cda6cd32bf66 /actionpack/lib/action_view/helpers | |
parent | 2dd43c3f804176d114cdbfeb8a0f92a43155baee (diff) | |
download | rails-e30ca001efa861cc13259ca8287837174b24e679.tar.gz rails-e30ca001efa861cc13259ca8287837174b24e679.tar.bz2 rails-e30ca001efa861cc13259ca8287837174b24e679.zip |
Yo dawg, I heard you like streaming. So I put a fiber, inside a block, inside a body, so you can stream.
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r-- | actionpack/lib/action_view/helpers/capture_helper.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/capture_helper.rb b/actionpack/lib/action_view/helpers/capture_helper.rb index f8b5605ed9..148d814ac7 100644 --- a/actionpack/lib/action_view/helpers/capture_helper.rb +++ b/actionpack/lib/action_view/helpers/capture_helper.rb @@ -139,6 +139,17 @@ module ActionView result unless content end + # The same as +content_for+ but when used with streaming flushes + # straight back to the layout. In other words, if you want to + # concatenate several times to the same buffer when rendering a given + # template, you should use +content_for+, if not, use +provide+ as it + # has better streaming support. + def provide(name, content = nil, &block) + content = capture(&block) if block_given? + @_view_flow.set(name, content) if content + 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. # |