1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Yield @content_for_ variables to templates #2058 [Sam Stephenson]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2094 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jamis Buck 2005-09-01 21:51:27 +00:00
parent 01af965a3e
commit e758c2e9db
4 changed files with 16 additions and 1 deletions

View file

@ -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.

View file

@ -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:

View file

@ -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

View file

@ -0,0 +1,2 @@
<title><%= yield :title %></title>
<%= yield %>