aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/template
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-08-09 01:37:03 -0300
committerYehuda Katz <wycats@gmail.com>2009-08-09 04:12:08 -0300
commit33f01fb1f6e0bf850e9366ef8203c4c944c27540 (patch)
treef42ab7b27049afca24289ab3b7e7720e93980b19 /actionpack/lib/action_view/template
parent0ab40b039bf7b7882a31ab187916bc2dc5a8ae7c (diff)
downloadrails-33f01fb1f6e0bf850e9366ef8203c4c944c27540.tar.gz
rails-33f01fb1f6e0bf850e9366ef8203c4c944c27540.tar.bz2
rails-33f01fb1f6e0bf850e9366ef8203c4c944c27540.zip
Cache some more things to improve partial perf
Diffstat (limited to 'actionpack/lib/action_view/template')
-rw-r--r--actionpack/lib/action_view/template/template.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/template/template.rb b/actionpack/lib/action_view/template/template.rb
index abe310b758..33d3f79ad3 100644
--- a/actionpack/lib/action_view/template/template.rb
+++ b/actionpack/lib/action_view/template/template.rb
@@ -7,19 +7,22 @@ require "action_view/template/resolver"
module ActionView
class Template
extend TemplateHandlers
- attr_reader :source, :identifier, :handler, :mime_type, :details
+ attr_reader :source, :identifier, :handler, :mime_type, :formats, :details
def initialize(source, identifier, handler, details)
@source = source
@identifier = identifier
@handler = handler
@details = details
+ @method_names = {}
format = details.delete(:format) || begin
# TODO: Clean this up
handler.respond_to?(:default_format) ? handler.default_format.to_sym.to_s : "html"
end
@mime_type = Mime::Type.lookup_by_extension(format.to_s)
+ @formats = [format.to_sym]
+ @formats << :html if format == :js
@details[:formats] = Array.wrap(format.to_sym)
end
@@ -90,7 +93,8 @@ module ActionView
def build_method_name(locals)
# TODO: is locals.keys.hash reliably the same?
- "_render_template_#{@identifier.hash}_#{__id__}_#{locals.keys.hash}".gsub('-', "_")
+ @method_names[locals.keys.hash] ||=
+ "_render_template_#{@identifier.hash}_#{__id__}_#{locals.keys.hash}".gsub('-', "_")
end
end
end