lib/render.js
function render(view, options) {
  var self = this;
  options = options || {};

  for (var name in settings._filters) {
    options[name] = settings._filters[name];
  }

  if (settings.helpers) {
    for (var k in settings.helpers) {
      var helper = settings.helpers[k];
      if (typeof helper === 'function') {
        helper = helper(self.req, self);
      }
      if (!options.hasOwnProperty(k)) {
        options[k] = helper;
      }
    }
  }

  if (settings.filters) {
    for (var name in settings.filters) {
      options[name] = settings.filters[name];
    }
  }

  // add request to options
  if (!options.request) {
    options.request = self.req;
  }
  // render view template
  _render(view, options, function (err, str) {
    if (err) {
      return self.req.next(err);
    }
    var layout = typeof options.layout === 'string' ? options.layout : settings.layout;
    if (options.layout === false || !layout) {
      return send(self, str);
    }
    // render layout template, add view str to layout's locals.body;
    options.body = str;
    _render(layout, options, function (err, str) {
      if (err) {
        return self.req.next(err);
      }
      send(self, str);
    });
  });
  return this;
}
function render(view, options) {
  var self = this;
  options = options || {};

  for (var name in settings._filters) {
    options[name] = settings._filters[name];
  }

  if (settings.helpers) {
    for (var k in settings.helpers) {
      var helper = settings.helpers[k];
      if (typeof helper === 'function') {
        helper = helper(self.req, self);
      }
      if (!options.hasOwnProperty(k)) {
        options[k] = helper;
      }
    }
  }

  if (settings.filters) {
    for (var name in settings.filters) {
      options[name] = settings.filters[name];
    }
  }

  // add request to options
  if (!options.request) {
    options.request = self.req;
  }
  // render view template
  _render(view, options, function (err, str) {
    if (err) {
      return self.req.next(err);
    }
    var layout = typeof options.layout === 'string' ? options.layout : settings.layout;
    if (options.layout === false || !layout) {
      return send(self, str);
    }
    // render layout template, add view str to layout's locals.body;
    options.body = str;
    _render(layout, options, function (err, str) {
      if (err) {
        return self.req.next(err);
      }
      send(self, str);
    });
  });
  return this;
}
function render ( view , options ) { var self = this ; options = options || { } ; for ( var name in settings . _filters ) { options [ name ] = settings . _filters [ name ] ; } if ( settings . helpers ) { for ( var k in settings . helpers ) { var helper = settings . helpers [ k ] ; if ( typeof helper === 'function' ) { helper = helper ( self . req , self ) ; } if ( ! options . hasOwnProperty ( k ) ) { options [ k ] = helper ; } } } if ( settings . filters ) { for ( var name in settings . filters ) { options [ name ] = settings . filters [ name ] ; } } // add request to options if ( ! options . request ) { options . request = self . req ; } // render view template _render ( view , options , function ( err , str ) { if ( err ) { return self . req . next ( err ) ; } var layout = typeof options . layout === 'string' ? options . layout : settings . layout ; if ( options . layout === false || ! layout ) { return send ( self , str ) ; } // render layout template, add view str to layout's locals.body; options . body = str ; _render ( layout , options , function ( err , str ) { if ( err ) { return self . req . next ( err ) ; } send ( self , str ) ; } ) ; } ) ; return this ; }
Render the view fill with options

@param {String} view, view name.
@param {Object} [options=null]
- {Boolean} layout, use layout or not, default is `true`.
@return {HttpServerResponse} this
Render the view fill with options