diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-10-28 17:10:52 +0100 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-10-28 17:10:52 +0100 |
commit | 1df157cd38c9246a87f0643f78be7f8fdb5bb474 (patch) | |
tree | 8b3d41f021a743c0697ea790e8f9b70cf26c793c /actionpack/lib | |
parent | 3e54a9a689915c28bc806498e5d1d1af91255fb0 (diff) | |
parent | ac50ee0edfa0df90ae7a8dd09f4a41ecbd1c7a94 (diff) | |
download | rails-1df157cd38c9246a87f0643f78be7f8fdb5bb474.tar.gz rails-1df157cd38c9246a87f0643f78be7f8fdb5bb474.tar.bz2 rails-1df157cd38c9246a87f0643f78be7f8fdb5bb474.zip |
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/routing/recognition_optimisation.rb | 8 | ||||
-rw-r--r-- | actionpack/lib/action_controller/test_process.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/base.rb | 11 | ||||
-rw-r--r-- | actionpack/lib/action_view/renderable.rb | 12 |
4 files changed, 19 insertions, 14 deletions
diff --git a/actionpack/lib/action_controller/routing/recognition_optimisation.rb b/actionpack/lib/action_controller/routing/recognition_optimisation.rb index 4935432d87..6c47ced6d1 100644 --- a/actionpack/lib/action_controller/routing/recognition_optimisation.rb +++ b/actionpack/lib/action_controller/routing/recognition_optimisation.rb @@ -153,13 +153,7 @@ module ActionController def clear_recognize_optimized! remove_recognize_optimized! - - class << self - def recognize_optimized(path, environment) - write_recognize_optimized! - recognize_optimized(path, environment) - end - end + write_recognize_optimized! end def remove_recognize_optimized! diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb index f84c48f102..7a31f0e8d5 100644 --- a/actionpack/lib/action_controller/test_process.rb +++ b/actionpack/lib/action_controller/test_process.rb @@ -218,7 +218,7 @@ module ActionController #:nodoc: # Returns the template of the file which was used to # render this response (or nil) def rendered_template - template.send(:_first_render) + template.instance_variable_get(:@_first_render) end # A shortcut to the flash. Returns an empty hash if no session flash exists. diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index e22978fe27..945246a39a 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -222,6 +222,7 @@ module ActionView #:nodoc: def initialize(view_paths = [], assigns_for_first_render = {}, controller = nil)#:nodoc: @assigns = assigns_for_first_render @assigns_added = nil + @_render_stack = [] @controller = controller @helpers = ProxyModule.new(self) self.view_paths = view_paths @@ -271,9 +272,13 @@ module ActionView #:nodoc: end end - private - attr_accessor :_first_render, :_last_render + # Access the current template being rendered. + # Returns a ActionView::Template object. + def template + @_render_stack.last + end + private # Evaluates the local assigns and controller ivars, pushes them to the view. def _evaluate_assigns_and_ivars #:nodoc: unless @assigns_added @@ -312,7 +317,7 @@ module ActionView #:nodoc: template elsif template = self.view_paths[template_file_name] template - elsif _first_render && template = self.view_paths["#{template_file_name}.#{_first_render.format_and_extension}"] + elsif @_render_stack.first && template = self.view_paths["#{template_file_name}.#{@_render_stack.first.format_and_extension}"] template elsif template_format == :js && template = self.view_paths["#{template_file_name}.html"] @template_format = :html diff --git a/actionpack/lib/action_view/renderable.rb b/actionpack/lib/action_view/renderable.rb index 0134bc988f..3d4dc6d522 100644 --- a/actionpack/lib/action_view/renderable.rb +++ b/actionpack/lib/action_view/renderable.rb @@ -25,13 +25,16 @@ module ActionView def render(view, local_assigns = {}) compile(local_assigns) - view.send(:_first_render=, self) unless view.send(:_first_render) - view.send(:_last_render=, self) + stack = view.instance_variable_get(:@_render_stack) + stack.push(self) + + # This is only used for TestResponse to set rendered_template + view.instance_variable_set(:@_first_render, self) unless view.instance_variable_get(:@_first_render) view.send(:_evaluate_assigns_and_ivars) view.send(:_set_controller_content_type, mime_type) if respond_to?(:mime_type) - view.send(method_name(local_assigns), local_assigns) do |*names| + result = view.send(method_name(local_assigns), local_assigns) do |*names| ivar = :@_proc_for_layout if view.instance_variable_defined?(ivar) and proc = view.instance_variable_get(ivar) view.capture(*names, &proc) @@ -39,6 +42,9 @@ module ActionView view.instance_variable_get(ivar) end end + + stack.pop + result end def method_name(local_assigns) |