diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/base.rb | 4 | ||||
-rw-r--r-- | actionpack/test/controller/new_render_test.rb | 9 | ||||
-rw-r--r-- | actionpack/test/fixtures/layouts/yield.rhtml | 2 |
4 files changed, 16 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 82f72df2bf..9189a076e5 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Yield @content_for_ variables to templates #2058 [Sam Stephenson] + * Make rendering an empty partial collection behave like :nothing => true #2080 [Sam Stephenson] * Add option to specify the singular name used by pagination. diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 923a1c28da..fbc9a66a05 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -243,7 +243,9 @@ module ActionView #:nodoc: # Get the selector for this template and names, then call the method. selector = @@compiled_templates.selector(identifier, names) evaluate_assigns - send(selector, *params) + send(selector, *params) do |*name| + instance_variable_get "@content_for_#{name.first || 'layout'}" + end end def pick_template_extension(template_path)#:nodoc: diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb index 7cb3643db5..7c829e68de 100644 --- a/actionpack/test/controller/new_render_test.rb +++ b/actionpack/test/controller/new_render_test.rb @@ -149,6 +149,10 @@ class NewRenderTestController < ActionController::Base render :text => "foo" end + def yield_content_for + render :action => "content_for", :layout => "yield" + end + def rescue_action(e) raise end private @@ -371,4 +375,9 @@ class NewRenderTest < Test::Unit::TestCase get :render_text_with_assigns assert_equal "world", assigns["hello"] end + + def test_yield_content_for + get :yield_content_for + assert_equal "<title>Putting stuff in the title!</title>\n\nGreat stuff!\n", @response.body + end end diff --git a/actionpack/test/fixtures/layouts/yield.rhtml b/actionpack/test/fixtures/layouts/yield.rhtml new file mode 100644 index 0000000000..482dc9022e --- /dev/null +++ b/actionpack/test/fixtures/layouts/yield.rhtml @@ -0,0 +1,2 @@ +<title><%= yield :title %></title> +<%= yield %> |