aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/layout.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-01-19 06:01:57 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2008-01-19 06:01:57 +0000
commit88bc014acc82129e55a7ae7505cb62bacd0d685d (patch)
tree855c3779b5eb527ba70ace6901d73242a05be7f0 /actionpack/lib/action_controller/layout.rb
parent16b129a68ca1770815107a3edb54090282349ba7 (diff)
downloadrails-88bc014acc82129e55a7ae7505cb62bacd0d685d.tar.gz
rails-88bc014acc82129e55a7ae7505cb62bacd0d685d.tar.bz2
rails-88bc014acc82129e55a7ae7505cb62bacd0d685d.zip
Revert r8669 for now, breaks Action Mailer. Reopens #10800.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8676 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/layout.rb')
-rw-r--r--actionpack/lib/action_controller/layout.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/layout.rb b/actionpack/lib/action_controller/layout.rb
index 0fbbfa8b05..a81efc2693 100644
--- a/actionpack/lib/action_controller/layout.rb
+++ b/actionpack/lib/action_controller/layout.rb
@@ -208,6 +208,12 @@ module ActionController #:nodoc:
conditions.inject({}) {|hash, (key, value)| hash.merge(key => [value].flatten.map {|action| action.to_s})}
end
+ def layout_directory_exists_cache
+ @@layout_directory_exists_cache ||= Hash.new do |h, dirname|
+ h[dirname] = File.directory? dirname
+ end
+ end
+
def default_layout_with_format(format, layout)
list = layout_list
if list.grep(%r{layouts/#{layout}\.#{format}(\.[a-z][0-9a-z]*)+$}).empty?
@@ -307,8 +313,13 @@ module ActionController #:nodoc:
end
end
+ # Does a layout directory for this class exist?
+ # we cache this info in a class level hash
def layout_directory?(layout_name)
- @template.finder.find_template_extension_from_handler(File.join('layouts', layout_name))
+ view_paths.find do |path|
+ next unless template_path = Dir[File.join(path, 'layouts', layout_name) + ".*"].first
+ self.class.send!(:layout_directory_exists_cache)[File.dirname(template_path)]
+ end
end
end
end