From 9a020bd8f924895c5e064b913df383b8ed77ac2a Mon Sep 17 00:00:00 2001 From: Lucas Mazza Date: Tue, 24 Jul 2012 16:19:14 -0300 Subject: [PATCH] Replace the flush parameter with a Hash. --- .../lib/action_view/helpers/capture_helper.rb | 8 ++++---- .../test/template/capture_helper_test.rb | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/actionpack/lib/action_view/helpers/capture_helper.rb b/actionpack/lib/action_view/helpers/capture_helper.rb index 397738dd98..9186855319 100644 --- a/actionpack/lib/action_view/helpers/capture_helper.rb +++ b/actionpack/lib/action_view/helpers/capture_helper.rb @@ -134,7 +134,7 @@ module ActionView # # <%# Add some other content, or use a different template: %> # - # <% content_for :navigation, true do %> + # <% content_for :navigation, flush: true do %> #
  • <%= link_to 'Login', :action => 'login' %>
  • # <% end %> # @@ -148,14 +148,14 @@ module ActionView # # WARNING: content_for is ignored in caches. So you shouldn't use it # for elements that will be fragment cached. - def content_for(name, content = nil, flush = false, &block) + def content_for(name, content = nil, options = {}, &block) if content || block_given? if block_given? - flush = content if content + options = content if content content = capture(&block) end if content - flush ? @view_flow.set(name, content) : @view_flow.append(name, content) + options[:flush] ? @view_flow.set(name, content) : @view_flow.append(name, content) end nil else diff --git a/actionpack/test/template/capture_helper_test.rb b/actionpack/test/template/capture_helper_test.rb index 17469f8c3e..234ac3252d 100644 --- a/actionpack/test/template/capture_helper_test.rb +++ b/actionpack/test/template/capture_helper_test.rb @@ -56,7 +56,7 @@ class CaptureHelperTest < ActionView::TestCase def test_content_for_with_multiple_calls_and_flush assert ! content_for?(:title) content_for :title, 'foo' - content_for :title, 'bar', true + content_for :title, 'bar', flush: true assert_equal 'bar', content_for(:title) end @@ -75,7 +75,7 @@ class CaptureHelperTest < ActionView::TestCase content_for :title do 'foo' end - content_for :title, true do + content_for :title, flush: true do 'bar' end assert_equal 'bar', content_for(:title) @@ -86,7 +86,7 @@ class CaptureHelperTest < ActionView::TestCase content_for :title do 'foo' end - content_for :title, nil, true do + content_for :title, nil, flush: true do 'bar' end assert_equal 'bar', content_for(:title) @@ -97,7 +97,7 @@ class CaptureHelperTest < ActionView::TestCase content_for :title do 'foo' end - content_for :title, false do + content_for :title, flush: false do 'bar' end assert_equal 'foobar', content_for(:title) @@ -117,11 +117,11 @@ class CaptureHelperTest < ActionView::TestCase def test_content_for_with_whitespace_block_and_flush assert ! content_for?(:title) content_for :title, 'foo' - content_for :title, true do + content_for :title, flush: true do output_buffer << " \n " nil end - content_for :title, 'bar', true + content_for :title, 'bar', flush: true assert_equal 'bar', content_for(:title) end @@ -131,9 +131,9 @@ class CaptureHelperTest < ActionView::TestCase assert_equal nil, content_for(:title) { output_buffer << 'bar'; nil } assert_equal nil, content_for(:title) { output_buffer << " \n "; nil } assert_equal 'foobar', content_for(:title) - assert_equal nil, content_for(:title, 'foo', true) - assert_equal nil, content_for(:title, true) { output_buffer << 'bar'; nil } - assert_equal nil, content_for(:title, true) { output_buffer << " \n "; nil } + assert_equal nil, content_for(:title, 'foo', flush: true) + assert_equal nil, content_for(:title, flush: true) { output_buffer << 'bar'; nil } + assert_equal nil, content_for(:title, flush: true) { output_buffer << " \n "; nil } assert_equal 'bar', content_for(:title) end