diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-08-09 18:39:44 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-08-09 18:39:44 +0100 |
commit | 2e50110eac439f3d5d292f1519ae7c79991eb91a (patch) | |
tree | 5ba10ebd6ddf0a7487754798993d3862ee9ec3b3 /actionpack/lib/action_view/template/template.rb | |
parent | a7f09bc12236d9e7bdc2ee34d5fe3c782d6ad385 (diff) | |
parent | bb1e1776914edf3be7e46b55036c18a64595f919 (diff) | |
download | rails-2e50110eac439f3d5d292f1519ae7c79991eb91a.tar.gz rails-2e50110eac439f3d5d292f1519ae7c79991eb91a.tar.bz2 rails-2e50110eac439f3d5d292f1519ae7c79991eb91a.zip |
Merge commit 'mainstream/master'
Diffstat (limited to 'actionpack/lib/action_view/template/template.rb')
-rw-r--r-- | actionpack/lib/action_view/template/template.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/template/template.rb b/actionpack/lib/action_view/template/template.rb index 4145045e2d..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 @@ -30,12 +33,12 @@ module ActionView # TODO: Figure out how to abstract this def variable_name - identifier[%r'_?(\w+)(\.\w+)*$', 1].to_sym + @variable_name ||= identifier[%r'_?(\w+)(\.\w+)*$', 1].to_sym end # TODO: Figure out how to abstract this def counter_name - "#{variable_name}_counter".to_sym + @counter_name ||= "#{variable_name}_counter".to_sym end # TODO: kill hax @@ -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 |