docs: function (view, locals, cb) {
      if (typeof locals === 'function') {
        cb = locals;
        locals = {};
      }
  
      // if `view` is a function, it's probably from chaining
      // a collection method
      if (typeof view === 'function') {
        return view.call(this);
      }
  
      // if `view` is a string, see if it's a cache view
      if (typeof view === 'string') {
        view = this.lookup(view);
      }
  
      locals = locals || {};
  
      // add `locals` to `view.contexts`
      view.ctx('render', locals);
      var data = this.cache.data;
      for (var key in locals) {
        if (locals.hasOwnProperty(key) && !data.hasOwnProperty(key)) {
          data[key] = locals[key];
        }
      }
  
      // handle `preRender` middleware
      this.handleView('preRender', view, locals);
  
      // build the context for the view
      var ctx = this.context(locals);
  
      // get the engine
      var engine = this.engine(locals.engine ? locals.engine : view.engine);
  
      if (typeof cb !== 'function') {
        throw this.error('render', 'callback');
      }
      if (typeof engine === 'undefined') {
        throw this.error('render', 'engine', path.extname(view.path));
      }
      if (!engine.hasOwnProperty('render')) {
        throw this.error('render', 'method', JSON.stringify(view));
      }
  
      // if it's not already compiled, do that first
      if (typeof view.fn !== 'function') {
        try {
          var isAsync = typeof cb === 'function';
          view = this.compile(view, locals, isAsync);
          return this.render(view, locals, cb);
        } catch (err) {
          this.emit('error', err);
          return cb.call(this, err);
        }
      }
  
      var context = this.context(view, ctx, locals);
  
      // render the view
      return engine.render(view.fn, context, function (err, res) {
        if (err) {
          this.emit('error', err);
          return cb.call(this, err);
        }
        // handle `postRender` middleware
        view.content = res;
        this.handle('postRender', view, locals, cb);
      }.bind(this));
    }