aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/template/template.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_view/template/template.rb')
-rw-r--r--actionpack/lib/action_view/template/template.rb28
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] ||=