function lookup(root, partial, options){

  var engine = options.settings['view engine'] || 'ejs';
  var desiredExt = '.' + engine;
  var ext = extname(partial) || desiredExt;
  var key = [ root, partial, ext ].join('-');

  if (options.cache && cache[key]) { return cache[key]; }

  // Make sure we use dirname in case of relative partials
  // ex: for partial('../user') look for /path/to/root/../user.ejs
  var dir = dirname(partial);
  var base = basename(partial, ext);

  // _ prefix takes precedence over the direct path
  // ex: for partial('user') look for /root/_user.ejs
  partial = resolve(root, dir,'_'+base+ext);
  if( exists(partial) ) {
    if (options.cache) { cache[key] = partial; }
    return partial;
  }

  // Try the direct path
  // ex: for partial('user') look for /root/user.ejs
  partial = resolve(root, dir, base+ext);
  if( exists(partial) ) {
    if (options.cache) { cache[key] = partial; }
    return partial;
  }

  // Try index
  // ex: for partial('user') look for /root/user/index.ejs
  partial = resolve(root, dir, base, 'index'+ext);
  if( exists(partial) ) {
    if (options.cache) { cache[key] = partial; }
    return partial;
  }

  // FIXME:
  // * there are other path types that Express 2.0 used to support but
  //   the structure of the lookup involved View class methods that we
  //   don't have access to any more
  // * we probaly need to pass the Express app's views folder path into
  //   this function if we want to support finding partials relative to
  //   it as well as relative to the current view
  // * we have no tests for finding partials that aren't relative to
  //   the calling view

  return null;
}
Lookup partial path from base path of current template:

  - partial `_<name>`
  - any `<name>/index`
  - non-layout `../<name>/index`
  - any `<root>/<name>`
  - partial `<root>/_<name>`

Options:

  - `cache` store the resolved path for the view, to avoid disk I/O

@param {String} root, full base path of calling template
@param {String} partial, name of the partial to lookup (can be a relative path)
@param {Object} options, for `options.cache` behavior
@return {String}
@api private