diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index d1569931ee8c2265b186ec5ef9a59cf225b64377..402ec82f0c8b9ca05faf270f71162912346573bb 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *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] diff --git a/actionpack/lib/action_controller/layout.rb b/actionpack/lib/action_controller/layout.rb index 32f7864182bd29b45b4389dce172a0a89452ebff..815a55739fb1811b86608ddc8ff69cb20e336fbe 100644 --- a/actionpack/lib/action_controller/layout.rb +++ b/actionpack/lib/action_controller/layout.rb @@ -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 diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb index 24c3a0e76505a1de0ef1f947c32f37cd7085b270..919875e8c38a1ce773b54ae47eb450db6b08fa61 100644 --- a/actionpack/test/controller/new_render_test.rb +++ b/actionpack/test/controller/new_render_test.rb @@ -34,6 +34,11 @@ def render_action_hello_world 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" @@ -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 "hello world, I'm here!", @response.body + end + def test_do_with_render_custom_code get :render_custom_code assert_response :missing diff --git a/actionpack/test/fixtures/layouts/standard.rhtml b/actionpack/test/fixtures/layouts/standard.rhtml index fcb28ec7553a4100f0d7d95ce0116e729074d308..368764e6f4432ae0abb5d1e3cf68a83c547ef092 100644 --- a/actionpack/test/fixtures/layouts/standard.rhtml +++ b/actionpack/test/fixtures/layouts/standard.rhtml @@ -1 +1 @@ -<%= @content_for_layout %> \ No newline at end of file +<%= @content_for_layout %><%= @variable_for_layout %> \ No newline at end of file