From 36eb1a686c831d5a14998bb9ac7cc60efa363373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 8 Mar 2010 20:57:33 +0100 Subject: Bring AM up to date with new rendering stack. --- actionmailer/lib/action_mailer/base.rb | 12 +++++------- actionmailer/lib/action_mailer/old_api.rb | 2 +- actionpack/lib/action_view/lookup_context.rb | 5 +++++ actionpack/lib/action_view/paths.rb | 8 ++++++++ actionpack/lib/action_view/render/rendering.rb | 2 ++ 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 6937d76b5d..bc708cca56 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -614,14 +614,12 @@ module ActionMailer #:nodoc: def each_template(paths, name, &block) #:nodoc: Array(paths).each do |path| - self.class.view_paths.each do |load_paths| - templates = load_paths.find_all(name, {}, path) - templates = templates.uniq_by { |t| t.details[:formats] } + templates = lookup_context.find_all(name, path) - unless templates.empty? - templates.each(&block) - return - end + unless templates.empty? + templates = templates.uniq_by { |t| t.details[:formats] } + templates.each(&block) + return end end end diff --git a/actionmailer/lib/action_mailer/old_api.rb b/actionmailer/lib/action_mailer/old_api.rb index 941261a5b4..aeb653c5db 100644 --- a/actionmailer/lib/action_mailer/old_api.rb +++ b/actionmailer/lib/action_mailer/old_api.rb @@ -206,7 +206,7 @@ module ActionMailer if String === @body @parts.unshift create_inline_part(@body) elsif @parts.empty? || @parts.all? { |p| p.content_disposition =~ /^attachment/ } - self.class.view_paths.first.find_all(@template, {}, @mailer_name).each do |template| + lookup_context.find_all(@template, @mailer_name).each do |template| @parts << create_inline_part(render(:_template => template), template.mime_type) end diff --git a/actionpack/lib/action_view/lookup_context.rb b/actionpack/lib/action_view/lookup_context.rb index 231882185f..608f1ef818 100644 --- a/actionpack/lib/action_view/lookup_context.rb +++ b/actionpack/lib/action_view/lookup_context.rb @@ -64,6 +64,11 @@ module ActionView @view_paths.find(name, key.details, prefix, partial || false, key) end + def find_all(name, prefix = nil, partial = false) + key = details_key + @view_paths.find_all(name, key.details, prefix, partial || false, key) + end + def template_exists?(name, prefix = nil, partial = false) key = details_key @view_paths.exists?(name, key.details, prefix, partial || false, key) diff --git a/actionpack/lib/action_view/paths.rb b/actionpack/lib/action_view/paths.rb index 1205d26e3b..82a9f9a13c 100644 --- a/actionpack/lib/action_view/paths.rb +++ b/actionpack/lib/action_view/paths.rb @@ -9,6 +9,14 @@ module ActionView #:nodoc: METHOD end + def find_all(path, details = {}, prefix = nil, partial = false, key=nil) + each do |resolver| + templates = resolver.find_all(path, details, prefix, partial, key) + return templates unless templates.empty? + end + [] + end + def find(path, details = {}, prefix = nil, partial = false, key=nil) each do |resolver| if template = resolver.find(path, details, prefix, partial, key) diff --git a/actionpack/lib/action_view/render/rendering.rb b/actionpack/lib/action_view/render/rendering.rb index d11f1fa2a7..0322d4b641 100644 --- a/actionpack/lib/action_view/render/rendering.rb +++ b/actionpack/lib/action_view/render/rendering.rb @@ -64,6 +64,8 @@ module ActionView Template::Text.new(options[:text], self.formats.try(:first)) elsif options.key?(:file) with_fallbacks { find_template(options[:file], options[:_prefix]) } + elsif options.key?(:_template) + options[:_template] elsif options.key?(:template) find_template(options[:template], options[:_prefix]) end -- cgit v1.2.3