diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-08-11 15:02:05 -0700 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-08-15 12:32:01 -0700 |
commit | 27adcd1c1a5cc566cfa8c5f8268b65ef01a7e865 (patch) | |
tree | 2e732c3909ec5a6a72e3dbcace8d0fdd2d57cc3d /actionpack/lib/action_view/template | |
parent | a363dba790d9d9f6284f7f857d872eca124805ee (diff) | |
download | rails-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')
-rw-r--r-- | actionpack/lib/action_view/template/handler.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/template/template.rb | 12 |
2 files changed, 11 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/template/handler.rb b/actionpack/lib/action_view/template/handler.rb index 3071c78174..7311e5e12f 100644 --- a/actionpack/lib/action_view/template/handler.rb +++ b/actionpack/lib/action_view/template/handler.rb @@ -26,7 +26,7 @@ module ActionView self.default_format = Mime::HTML def self.call(template) - "#{name}.new(self).render(template, local_assigns)" + raise "Need to implement #{self.class.name}#call(template)" end def initialize(view = nil) 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 |