Build a callback that renders on success or errors on failure
function renderCallback(req, res, template) {
    return function(err, data) {
      if (err) {
        handleError(req, res, err);
      } else {
        render(req, res, template, data);
      }
    };
  }