diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-08-17 19:46:06 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-08-17 19:46:06 -0300 |
commit | c01c8967a02537f132d437d5ae15332982119651 (patch) | |
tree | 76ed47f6bffd5fe1aa11c65cd32b222d881f43aa /actionpack/lib/action_view/template/template.rb | |
parent | 770fca10fba68fa14308f33e923493e6f63bfa35 (diff) | |
parent | ccf28d2499d1b4e2aba41291eb800e0e02120923 (diff) | |
download | rails-c01c8967a02537f132d437d5ae15332982119651.tar.gz rails-c01c8967a02537f132d437d5ae15332982119651.tar.bz2 rails-c01c8967a02537f132d437d5ae15332982119651.zip |
Merge commit 'rails/master'
Conflicts:
activerecord/lib/active_record/calculations.rb
Diffstat (limited to 'actionpack/lib/action_view/template/template.rb')
-rw-r--r-- | actionpack/lib/action_view/template/template.rb | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/template/template.rb b/actionpack/lib/action_view/template/template.rb index 33d3f79ad3..7d6964e3e3 100644 --- a/actionpack/lib/action_view/template/template.rb +++ b/actionpack/lib/action_view/template/template.rb @@ -26,9 +26,16 @@ 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) + 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 @@ -90,7 +97,22 @@ module ActionView raise ActionView::TemplateError.new(self, {}, e) end end - + + class LocalsKey + @hash_keys = Hash.new {|h,k| h[k] = Hash.new {|h,k| h[k] = {} } } + + def self.get(*locals) + @hash_keys[*locals] ||= new(klass, format, locale) + end + + attr_accessor :hash + def initialize(klass, format, locale) + @hash = locals.hash + end + + alias_method :eql?, :equal? + end + def build_method_name(locals) # TODO: is locals.keys.hash reliably the same? @method_names[locals.keys.hash] ||= |