diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2014-09-23 02:06:08 +0900 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2014-09-23 02:06:08 +0900 |
commit | 585e75696b31395aee895e5366e331c07c3f5ee1 (patch) | |
tree | 49ccfa225de09ea02560b1dabbf85a40cca728ab | |
parent | ca67632674e62426bf8b421d672692592e986091 (diff) | |
download | rails-585e75696b31395aee895e5366e331c07c3f5ee1.tar.gz rails-585e75696b31395aee895e5366e331c07c3f5ee1.tar.bz2 rails-585e75696b31395aee895e5366e331c07c3f5ee1.zip |
Revert "Merge pull request #16888 from jejacks0n/render_template"
This reverts commit 07635a74b5ee08dcba3f6617def6230d8f114fe5, reversing
changes made to 1b5f61a025b6ce1ee52b7148e3ed2a9acbde28b9.
Reason: it's not ready :bomb:, see https://github.com/rails/rails/pull/16888#issuecomment-56400816
-rw-r--r-- | actionview/CHANGELOG.md | 9 | ||||
-rw-r--r-- | actionview/lib/action_view/rendering.rb | 4 | ||||
-rw-r--r-- | actionview/test/actionpack/controller/render_test.rb | 23 | ||||
-rw-r--r-- | guides/source/4_2_release_notes.md | 11 |
4 files changed, 20 insertions, 27 deletions
diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index 8ac74dc938..ed58933472 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,12 +1,3 @@ -* Changed the meaning of `render "foo/bar"`. - - Previously, calling `render "foo/bar"` in a controller action is equivalent - to `render file: "foo/bar"`. In Rails 4.2, this has been changed to mean - `render template: "foo/bar"` instead. If you need to render a file, please - change your code to use the explicit form (`render file: "foo/bar"`) instead. - - *Jeremy Jackson* - * Add support for ARIA attributes in tags. Example: diff --git a/actionview/lib/action_view/rendering.rb b/actionview/lib/action_view/rendering.rb index 5cbdfdf6c0..81d5836a8c 100644 --- a/actionview/lib/action_view/rendering.rb +++ b/actionview/lib/action_view/rendering.rb @@ -108,7 +108,7 @@ module ActionView end # Normalize args by converting render "foo" to render :action => "foo" and - # render "foo/bar" to render :template => "foo/bar". + # render "foo/bar" to render :file => "foo/bar". # :api: private def _normalize_args(action=nil, options={}) options = super(action, options) @@ -118,7 +118,7 @@ module ActionView options = action when String, Symbol action = action.to_s - key = action.include?(?/) ? :template : :action + key = action.include?(?/) ? :file : :action options[key] = action else options[:partial] = action diff --git a/actionview/test/actionpack/controller/render_test.rb b/actionview/test/actionpack/controller/render_test.rb index 563caee8a2..b3b51ae583 100644 --- a/actionview/test/actionpack/controller/render_test.rb +++ b/actionview/test/actionpack/controller/render_test.rb @@ -91,17 +91,17 @@ class TestController < ApplicationController # :ported: def render_hello_world - render "test/hello_world" + render :template => "test/hello_world" end def render_hello_world_with_last_modified_set response.last_modified = Date.new(2008, 10, 10).to_time - render "test/hello_world" + render :template => "test/hello_world" end # :ported: compatibility def render_hello_world_with_forward_slash - render "/test/hello_world" + render :template => "/test/hello_world" end # :ported: @@ -111,7 +111,7 @@ class TestController < ApplicationController # :deprecated: def render_template_in_top_directory_with_slash - render '/shared' + render :template => '/shared' end # :ported: @@ -160,6 +160,13 @@ class TestController < ApplicationController end # :ported: + def render_file_as_string_with_instance_variables + @secret = 'in the sauce' + path = File.expand_path(File.join(File.dirname(__FILE__), '../../fixtures/test/render_file_with_ivar')) + render path + end + + # :ported: def render_file_not_using_full_path @secret = 'in the sauce' render :file => 'test/render_file_with_ivar' @@ -187,7 +194,7 @@ class TestController < ApplicationController def render_file_as_string_with_locals path = File.expand_path(File.join(File.dirname(__FILE__), '../../fixtures/test/render_file_with_locals')) - render file: path, :locals => {:secret => 'in the sauce'} + render path, :locals => {:secret => 'in the sauce'} end def accessing_request_in_template @@ -787,6 +794,12 @@ class RenderTest < ActionController::TestCase end # :ported: + def test_render_file_as_string_with_instance_variables + get :render_file_as_string_with_instance_variables + assert_equal "The secret is in the sauce\n", @response.body + end + + # :ported: def test_render_file_not_using_full_path get :render_file_not_using_full_path assert_equal "The secret is in the sauce\n", @response.body diff --git a/guides/source/4_2_release_notes.md b/guides/source/4_2_release_notes.md index 0e0307de66..c59affea8f 100644 --- a/guides/source/4_2_release_notes.md +++ b/guides/source/4_2_release_notes.md @@ -149,13 +149,6 @@ individual components for new deprecations in this release. The following changes may require immediate action upon upgrade. -### `render` with a String argument - -Previously, calling `render "foo/bar"` in a controller action is equivalent to -`render file: "foo/bar"`. In Rails 4.2, this has been changed to mean `render template: "foo/bar"` -instead. If you need to render a file, please change your code to use the -explicit form (`render file: "foo/bar"`) instead. - ### `respond_with` / class-level `respond_to` `respond_with` and the corresponding class-level `respond_to` have been moved to @@ -506,10 +499,6 @@ Please refer to the [Changelog][action-view] for detailed changes. ### Notable changes -* `render "foo/bar"` now expands to `render template: "foo/bar"` instead of - `render file: "foo/bar"`. - ([Pull Request](https://github.com/rails/rails/pull/16888)) - * Introduced a `#{partial_name}_iteration` special local variable for use with partials that are rendered with a collection. It provides access to the current state of the iteration via the `#index`, `#size`, `#first?` and |