Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8541

Show
Ignore:
Timestamp:
01/03/08 15:28:36 (4 months ago)
Author:
david
Message:

Fixed rendering of partials with layout when done from site layout (closes #9209) [antramm]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r8529 r8541  
    11*SVN* 
     2 
     3* Fixed rendering of partials with layout when done from site layout #9209 [antramm] 
    24 
    35* Fix atom_feed_helper to comply with the atom spec.  Closes #10672 [xaviershay] 
  • trunk/actionpack/lib/action_view/base.rb

    r8404 r8541  
    339339 
    340340          if block_given? 
    341             @content_for_layout = capture(&block) 
    342             concat(render(options.merge(:partial => "#{path}/#{partial_name}")), block.binding) 
     341            wrap_content_for_layout capture(&block) do  
     342              concat(render(options.merge(:partial => "#{path}/#{partial_name}")), block.binding) 
     343            end 
    343344          else 
    344             @content_for_layout = render(options) 
    345             render(options.merge(:partial => "#{path}/#{partial_name}")) 
     345            wrap_content_for_layout render(options) do 
     346              render(options.merge(:partial => "#{path}/#{partial_name}")) 
     347            end 
    346348          end 
    347349        elsif options[:file] 
     
    442444 
    443445    private 
     446      def wrap_content_for_layout(content) 
     447        original_content_for_layout = @content_for_layout 
     448        @content_for_layout = content 
     449        returning(yield) { @content_for_layout = original_content_for_layout } 
     450      end 
     451   
    444452      def find_full_template_path(template_path, extension) 
    445453        file_name = "#{template_path}.#{extension}" 
  • trunk/actionpack/test/controller/new_render_test.rb

    r8499 r8541  
    362362  end 
    363363 
     364  def render_call_to_partial_with_layout_in_main_layout_and_within_content_for_layout 
     365    render :action => "calling_partial_with_layout" 
     366  end 
     367 
    364368  def render_using_layout_around_block 
    365369    render :action => "using_layout_around_block" 
    366370  end 
    367371 
     372  def render_using_layout_around_block_in_main_layout_and_within_content_for_layout 
     373    render :action => "using_layout_around_block" 
     374  end 
     375   
    368376  def rescue_action(e) raise end 
    369377     
     
    388396        when "action_talk_to_layout", "layout_overriding_layout" 
    389397          "layouts/talk_from_action" 
     398        when "render_call_to_partial_with_layout_in_main_layout_and_within_content_for_layout" 
     399          "layouts/partial_with_layout" 
     400        when "render_using_layout_around_block_in_main_layout_and_within_content_for_layout" 
     401          "layouts/block_with_layout" 
    390402      end 
    391403    end 
     
    826838    assert_equal "Before (David)\nInside from partial (David)\nAfter", @response.body 
    827839  end 
    828    
     840 
     841  def test_render_call_to_partial_with_layout_in_main_layout_and_within_content_for_layout 
     842    get :render_call_to_partial_with_layout_in_main_layout_and_within_content_for_layout 
     843    assert_equal "Before (Anthony)\nInside from partial (Anthony)\nAfter\nBefore (David)\nInside from partial (David)\nAfter\nBefore (Ramm)\nInside from partial (Ramm)\nAfter", @response.body 
     844  end 
     845 
    829846  def test_using_layout_around_block 
    830     get :using_layout_around_block 
     847    get :render_using_layout_around_block 
    831848    assert_equal "Before (David)\nInside from block\nAfter", @response.body 
    832849  end 
     850 
     851  def test_using_layout_around_block_in_main_layout_and_within_content_for_layout 
     852    get :render_using_layout_around_block_in_main_layout_and_within_content_for_layout 
     853    assert_equal "Before (Anthony)\nInside from first block in layout\nAfter\nBefore (David)\nInside from block\nAfter\nBefore (Ramm)\nInside from second block in layout\nAfter\n", @response.body 
     854  end 
     855 
    833856end