Changeset 1911
- Timestamp:
- 07/24/05 13:20:29 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_view/helpers/capture_helper.rb
r1459 r1911 83 83 # for elements that are going to be fragment cached. 84 84 def content_for(name, &block) 85 base = controller.instance_variable_get(instance_var_name(name)) || ""85 base = instance_variable_get(instance_var_name(name)) || "" 86 86 data = capture(&block) 87 controller.instance_variable_set(instance_var_name(name), base + data)87 instance_variable_set(instance_var_name(name), base + data) 88 88 data 89 89 end trunk/actionpack/test/controller/capture_test.rb
r1665 r1911 4 4 def self.controller_name; "test"; end 5 5 def self.controller_path; "test"; end 6 7 def content_for 8 render :layout => "talk_from_action" 9 end 6 10 7 11 def rescue_action(e) raise end … … 28 32 assert_equal "Dreamy days", @response.body.strip 29 33 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 30 39 31 40 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> 2 2 <%= @content_for_layout -%>