diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-08-06 20:08:27 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-08-06 20:11:21 -0500 |
commit | b2504f8ba0f9baadb9298647fd58ef2c136f9aae (patch) | |
tree | 205a73e5d381dc5e8c524d2858fe7f15d142e332 /actionpack/lib | |
parent | ed8a882e47e07b470b71cacd8cd50e251dca4d27 (diff) | |
download | rails-b2504f8ba0f9baadb9298647fd58ef2c136f9aae.tar.gz rails-b2504f8ba0f9baadb9298647fd58ef2c136f9aae.tar.bz2 rails-b2504f8ba0f9baadb9298647fd58ef2c136f9aae.zip |
Tidy up ActionMailer rendering logic to take advantage of view path cache instead of using file system lookups
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/base.rb | 5 | ||||
-rw-r--r-- | actionpack/lib/action_view/template.rb | 10 |
2 files changed, 13 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index bdcb1dc246..ad59d92086 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -300,6 +300,8 @@ module ActionView #:nodoc: # # => 'users/legacy.rhtml' # def pick_template(template_path) + return template_path if template_path.respond_to?(:render) + path = template_path.sub(/^\//, '') if m = path.match(/(.*)\.(\w+)$/) template_file_name, template_file_extension = m[1], m[2] @@ -343,7 +345,8 @@ module ActionView #:nodoc: ActiveSupport::Deprecation.warn("use_full_path option has been deprecated and has no affect.", caller) end - if defined?(ActionMailer) && defined?(ActionMailer::Base) && controller.is_a?(ActionMailer::Base) && !template_path.include?("/") + if defined?(ActionMailer) && defined?(ActionMailer::Base) && controller.is_a?(ActionMailer::Base) && + template_path.is_a?(String) && !template_path.include?("/") raise ActionViewError, <<-END_ERROR Due to changes in ActionMailer, you need to provide the mailer_name along with the template name. diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index b281ff61f2..5dc6708431 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -22,6 +22,14 @@ module ActionView #:nodoc: end memoize :format_and_extension + def multipart? + format && format.include?('.') + end + + def content_type + format.gsub('.', '/') + end + def mime_type Mime::Type.lookup_by_extension(format) if format end @@ -84,7 +92,7 @@ module ActionView #:nodoc: # [base_path, name, format, extension] def split(file) if m = file.match(/^(.*\/)?([^\.]+)\.?(\w+)?\.?(\w+)?\.?(\w+)?$/) - if m[5] # Mulipart formats + if m[5] # Multipart formats [m[1], m[2], "#{m[3]}.#{m[4]}", m[5]] elsif m[4] # Single format [m[1], m[2], m[3], m[4]] |