# File lib/action_view/template/resolver.rb, line 46 46: def to_s 47: @path.to_s 48: end
# File lib/action_view/template/resolver.rb, line 58 58: def build_path(name, prefix, partial, details) 59: path = "" 60: path << "#{prefix}/" unless prefix.empty? 61: path << (partial ? "_#{name}" : name) 62: path 63: end
Extract handler and formats from path. If a format cannot be a found neither from the path, or the handler, we should return the array of formats given to the resolver.
# File lib/action_view/template/resolver.rb, line 88 88: def extract_handler_and_format(path, default_formats) 89: pieces = File.basename(path).split(".") 90: pieces.shift 91: 92: handler = Template.handler_class_for_extension(pieces.pop) 93: 94: if pieces.last == "html" && pieces[2] == "text" 95: correct_path = path.gsub(/\.text\.html/, ".html") 96: ActiveSupport::Deprecation.warn "The file `#{path}` uses the deprecated format `text.html`. Please rename it to #{correct_path}", caller 97: end 98: 99: if pieces.last == "plain" && pieces[2] == "text" 100: correct_path = path.gsub(/\.text\.plain/, ".text") 101: pieces.pop 102: ActiveSupport::Deprecation.warn "The file `#{path}` uses the deprecated format `text.plain`. Please rename it to #{correct_path}", caller 103: end 104: 105: format = pieces.last && Mime[pieces.last] && pieces.pop.to_sym 106: format ||= handler.default_format if handler.respond_to?(:default_format) 107: format ||= default_formats 108: 109: [handler, format] 110: end
# File lib/action_view/template/resolver.rb, line 53 53: def find_templates(name, prefix, partial, details) 54: path = build_path(name, prefix, partial, details) 55: query(path, EXTENSION_ORDER.map { |ext| details[ext] }, details[:formats]) 56: end
# File lib/action_view/template/resolver.rb, line 65 65: def query(path, exts, formats) 66: query = File.join(@path, path) 67: 68: exts.each do |ext| 69: query << '{' << ext.map {|e| e && ".#{e}" }.join(',') << ',}' 70: end 71: 72: query.gsub!(/\{\.html,/, "{.html,.text.html,") 73: query.gsub!(/\{\.text,/, "{.text,.text.plain,") 74: 75: Dir[query].reject { |p| File.directory?(p) }.map do |p| 76: handler, format = extract_handler_and_format(p, formats) 77: 78: contents = File.open(p, "rb") {|io| io.read } 79: 80: Template.new(contents, File.expand_path(p), handler, 81: :virtual_path => path, :format => format) 82: end 83: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.