aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/template/template.rb
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-08-11 15:02:05 -0700
committerYehuda Katz <wycats@gmail.com>2009-08-15 12:32:01 -0700
commit27adcd1c1a5cc566cfa8c5f8268b65ef01a7e865 (patch)
tree2e732c3909ec5a6a72e3dbcace8d0fdd2d57cc3d /actionpack/lib/action_view/template/template.rb
parenta363dba790d9d9f6284f7f857d872eca124805ee (diff)
downloadrails-27adcd1c1a5cc566cfa8c5f8268b65ef01a7e865.tar.gz
rails-27adcd1c1a5cc566cfa8c5f8268b65ef01a7e865.tar.bz2
rails-27adcd1c1a5cc566cfa8c5f8268b65ef01a7e865.zip
Clean up ActionView some:
* Call _evaluate_assigns_and_ivars at the two entry points so we don't have to do a check at every render. * Make template.render viable without having to go through a wrapper method * Remove old TemplateHandler#render(template, local_assigns) path so we don't have to set self.template every time we render a template. * Move Template rescuing code to Template#render so it gets caught every time. * Pull in some tests from Pratik that test render @object in ActionView
Diffstat (limited to 'actionpack/lib/action_view/template/template.rb')
-rw-r--r--actionpack/lib/action_view/template/template.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/template/template.rb b/actionpack/lib/action_view/template/template.rb
index 33d3f79ad3..f6270e5616 100644
--- a/actionpack/lib/action_view/template/template.rb
+++ b/actionpack/lib/action_view/template/template.rb
@@ -26,9 +26,17 @@ module ActionView
@details[:formats] = Array.wrap(format.to_sym)
end
- def render(view, locals, &blk)
+ def render(view, locals, &block)
method_name = compile(locals, view)
- view.send(method_name, locals, &blk)
+ block ||= proc {|*names| view._layout_for(names) }
+ view.send(method_name, locals, &block)
+ rescue Exception => e
+ if e.is_a?(TemplateError)
+ e.sub_template_of(self)
+ raise e
+ else
+ raise TemplateError.new(self, view.assigns, e)
+ end
end
# TODO: Figure out how to abstract this