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

Changeset 1911

Show
Ignore:
Timestamp:
07/24/05 13:20:29 (3 years ago)
Author:
david
Message:

Fixed regression for content_for #1820 [Stefan Kaes]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_view/helpers/capture_helper.rb

    r1459 r1911  
    8383      # for elements that are going to be fragment cached.  
    8484      def content_for(name, &block)                       
    85         base = controller.instance_variable_get(instance_var_name(name)) || "" 
     85        base = instance_variable_get(instance_var_name(name)) || "" 
    8686        data = capture(&block) 
    87         controller.instance_variable_set(instance_var_name(name), base + data) 
     87        instance_variable_set(instance_var_name(name), base + data) 
    8888        data 
    8989      end 
  • trunk/actionpack/test/controller/capture_test.rb

    r1665 r1911  
    44  def self.controller_name; "test"; end 
    55  def self.controller_path; "test"; end 
     6 
     7  def content_for 
     8    render :layout => "talk_from_action" 
     9  end 
    610 
    711  def rescue_action(e) raise end 
     
    2832    assert_equal "Dreamy days", @response.body.strip 
    2933  end 
     34   
     35  def test_content_for 
     36    get :content_for 
     37    assert_equal "<title>Putting stuff in the title!</title>\n\nGreat stuff!", @response.body 
     38  end 
    3039 
    3140  def test_update_element_with_capture 
  • trunk/actionpack/test/fixtures/layouts/talk_from_action.rhtml

    r1904 r1911  
    1 <title><%= @title %></title> 
     1<title><%= @title || @content_for_title %></title> 
    22<%= @content_for_layout -%>