diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-08-09 09:32:16 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-08-09 09:32:16 -0700 |
commit | 233696a02771abebf867dacc02bce7124b5aa647 (patch) | |
tree | c45858b3d470071d245be77a8df314a882f62ac1 | |
parent | 37b77c6ae7effdba51ecd8b3b91e2cdb0020b6aa (diff) | |
download | rails-233696a02771abebf867dacc02bce7124b5aa647.tar.gz rails-233696a02771abebf867dacc02bce7124b5aa647.tar.bz2 rails-233696a02771abebf867dacc02bce7124b5aa647.zip |
use functional style to build a list of template objects
-rw-r--r-- | actionpack/lib/action_view/template/resolver.rb | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb index d0b5c76f1a..3abc1b861d 100644 --- a/actionpack/lib/action_view/template/resolver.rb +++ b/actionpack/lib/action_view/template/resolver.rb @@ -131,21 +131,24 @@ module ActionView def query(path, details, formats) query = build_query(path, details) - templates = [] + + # deals with case-insensitive file systems. sanitizer = Hash.new { |h,dir| h[dir] = Dir["#{dir}/*"] } - Dir[query].each do |template| - next if File.directory?(template) - next unless sanitizer[File.dirname(template)].include?(template) + template_paths = Dir[query].reject { |filename| + File.directory?(filename) || + !sanitizer[File.dirname(filename)].include?(filename) + } + template_paths.map { |template| handler, format = extract_handler_and_format(template, formats) contents = File.binread template - templates << Template.new(contents, File.expand_path(template), handler, - :virtual_path => path.virtual, :format => format, :updated_at => mtime(template)) - end - - templates + Template.new(contents, File.expand_path(template), handler, + :virtual_path => path.virtual, + :format => format, + :updated_at => mtime(template)) + } end # Helper for building query glob string based on resolver's pattern. |