diff options
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/capture_helper.rb | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/actionpack/lib/action_view/helpers/capture_helper.rb b/actionpack/lib/action_view/helpers/capture_helper.rb index 837305d96c..25e62f78fb 100644 --- a/actionpack/lib/action_view/helpers/capture_helper.rb +++ b/actionpack/lib/action_view/helpers/capture_helper.rb @@ -32,7 +32,7 @@ module ActionView # def capture(*args, &block) if @output_buffer - with_temporary_output_buffer { yield *args } + with_output_buffer { block.call(*args) } else block.call(*args) end @@ -115,27 +115,17 @@ module ActionView # <tt><%= yield :footer %></tt>. def content_for(name, content = nil, &block) ivar = "@content_for_#{name}" - instance_variable_set("@content_for_#{name}", "#{instance_variable_get(ivar)}#{block_given? ? capture(&block) : content}") + content = capture(&block) if block_given? + instance_variable_set(ivar, "#{instance_variable_get(ivar)}#{content}") end private - def with_temporary_output_buffer - @output_buffer, old_buffer = '', @output_buffer + def with_output_buffer(buf = '') + @output_buffer, old_buffer = buf, @output_buffer yield - @output_buffer ensure @output_buffer = old_buffer end - - def erb_content_for(name, &block) - ivar = "@content_for_#{name}" - instance_variable_set(ivar, "#{instance_variable_get(ivar)}#{capture(&block)}") - end - - def block_content_for(name) - ivar = "@content_for_#{name}" - instance_variable_set(ivar, "#{instance_variable_get(ivar)}#{yield}") - end end end end |