added a check for res.locals.isAPI inside res.render, instead of doing it all over the place in code

This commit is contained in:
psychobunny
2014-03-09 19:54:16 -04:00
parent 1b3f089804
commit faf3de7e27
2 changed files with 5 additions and 5 deletions

View File

@@ -80,11 +80,7 @@ Controllers.home = function(req, res, next) {
});
}
}, function (err, data) {
if (res.locals.isAPI) {
res.json(data);
} else {
res.render('home', data);
}
});
};

View File

@@ -276,6 +276,10 @@ middleware.processRender = function(req, res, next) {
fn = defaultFn;
}
if (res.locals.isAPI) {
return res.json(options);
}
render.call(self, template, options, function(err, str) {
if (res.locals.footer) {
str = str + res.locals.footer;