def render_mail(options = @method)
@_missing_templates = false
options = {:action => {:html => options, :text => options}} if !options.is_a?(Hash)
opts_hash = {}
opts = options.dup
actions = opts.delete(:action) if opts[:action].is_a?(Hash)
templates = opts.delete(:template) if opts[:template].is_a?(Hash)
[:html, :text].each do |fmt|
opts_hash[fmt] = opts.delete(fmt)
opts_hash[fmt] ||= actions[fmt] if actions && actions[fmt]
opts_hash[:template] = templates[fmt] if templates && templates[fmt]
end
{ :html => "rawhtml=", :text => "text="}.each do |fmt,meth|
begin
local_opts = opts.merge(:format => fmt)
local_opts.merge!(:layout => false) if opts_hash[fmt].is_a?(String)
clear_content
value = render opts_hash[fmt], local_opts
@mail.send(meth,value) unless value.nil? || value.empty?
rescue Merb::ControllerExceptions::TemplateNotFound => e
if @_missing_templates
Merb.logger.error(e)
else
@_missing_templates = true
end
end
end
@mail
end