提交 cb0e27ce 编写于 作者: D David Heinemeier Hansson

Fix that render :text didn't interpolate instance variables (Closes #2629, #2626) [skaes]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2777 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 fb619127
*SVN*
* Fix that render :text didn't interpolate instance variables #2629, #2626 [skaes]
* Fix line number detection and escape RAILS_ROOT in backtrace Regexp [Nicholas Seckar]
* Fixed document.getElementsByClassName from Prototype to be speedy again [Sam Stephenson]
......
......@@ -219,6 +219,7 @@ def render_with_a_layout(options = nil, deprecated_status = nil, deprecated_layo
end
erase_render_results
add_variables_to_assigns
@template.instance_variable_set("@content_for_layout", content_for_layout)
render_text(@template.render_file(layout, true), deprecated_status)
else
......
......@@ -35,6 +35,11 @@ def render_text_hello_world
render :text => "hello world"
end
def render_text_hello_world_with_layout
@variable_for_layout = ", I'm here!"
render :text => "hello world", :layout => true
end
def render_custom_code
render :text => "hello world", :status => "404 Moved"
end
......@@ -169,6 +174,7 @@ def determine_layout
case action_name
when "hello_world", "layout_test", "rendering_without_layout",
"rendering_nothing_on_layout", "render_text_hello_world",
"render_text_hello_world_with_layout",
"partial_only", "partial_only_with_layout",
"accessing_params_in_template",
"accessing_params_in_template_with_layout",
......@@ -226,6 +232,11 @@ def test_do_with_render_text
assert_equal "hello world", @response.body
end
def test_do_with_render_text_and_layout
get :render_text_hello_world_with_layout
assert_equal "<html>hello world, I'm here!</html>", @response.body
end
def test_do_with_render_custom_code
get :render_custom_code
assert_response :missing
......
<html><%= @content_for_layout %></html>
\ No newline at end of file
<html><%= @content_for_layout %><%= @variable_for_layout %></html>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册