lib/action_mailer/base.rb in actionmailer-2.2.2 vs lib/action_mailer/base.rb in actionmailer-2.2.3
- old
+ new
@@ -427,11 +427,11 @@
end
def register_template_extension(extension)
ActiveSupport::Deprecation.warn(
"ActionMailer::Base.register_template_extension has been deprecated." +
- "Use ActionView::Base.register_template_extension instead", caller)
+ "Use ActionView::Template.register_template_handler instead", caller)
end
def template_root
self.view_paths && self.view_paths.first
end
@@ -547,11 +547,16 @@
@body ||= {}
@mime_version = @@default_mime_version.dup if @@default_mime_version
end
def render_message(method_name, body)
+ if method_name.respond_to?(:content_type)
+ @current_template_content_type = method_name.content_type
+ end
render :file => method_name, :body => body
+ ensure
+ @current_template_content_type = nil
end
def render(opts)
body = opts.delete(:body)
if opts[:file] && (opts[:file] !~ /\// && !opts[:file].respond_to?(:render))
@@ -566,11 +571,15 @@
@template = old_template
end
end
def default_template_format
- :html
+ if @current_template_content_type
+ Mime::Type.lookup(@current_template_content_type).to_sym
+ else
+ :html
+ end
end
def candidate_for_layout?(options)
!@template.send(:_exempt_from_layout?, default_template_name)
end
@@ -586,10 +595,12 @@
def template_path
"#{template_root}/#{mailer_name}"
end
def initialize_template_class(assigns)
- ActionView::Base.new(view_paths, assigns, self)
+ template = ActionView::Base.new(view_paths, assigns, self)
+ template.template_format = default_template_format
+ template
end
def sort_parts(parts, order = [])
order = order.collect { |s| s.downcase }