aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/base.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-10-28 11:06:08 -0500
committerJoshua Peek <josh@joshpeek.com>2008-10-28 11:06:08 -0500
commitac50ee0edfa0df90ae7a8dd09f4a41ecbd1c7a94 (patch)
tree5520adefae997928b844fb456fd106b3c08de6cd /actionpack/lib/action_view/base.rb
parent0f651aec4eb4630945d02571fe542414ef628c5c (diff)
downloadrails-ac50ee0edfa0df90ae7a8dd09f4a41ecbd1c7a94.tar.gz
rails-ac50ee0edfa0df90ae7a8dd09f4a41ecbd1c7a94.tar.bz2
rails-ac50ee0edfa0df90ae7a8dd09f4a41ecbd1c7a94.zip
Track rendered templates in stack so the current template can always be accessed. Added ActionView::Base#template to access the template object.
Diffstat (limited to 'actionpack/lib/action_view/base.rb')
-rw-r--r--actionpack/lib/action_view/base.rb11
1 files changed, 8 insertions, 3 deletions
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