Permalink
Browse files

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
  • Loading branch information...
1 parent 01af965 commit e758c2e9db63d8b0a01c659a74e8f1dec22a72d0 @jamis jamis committed Sep 1, 2005
View
@@ -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.
@@ -243,7 +243,9 @@ def compile_and_render_template(extension, template = nil, file_path = nil, loca
# 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:
@@ -149,6 +149,10 @@ def render_text_with_assigns
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 @@ def test_render_text_with_assigns
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
@@ -0,0 +1,2 @@
+<title><%= yield :title %></title>
+<%= yield %>

0 comments on commit e758c2e

Please sign in to comment.