mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
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:
@@ -80,11 +80,7 @@ Controllers.home = function(req, res, next) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, function (err, data) {
|
}, function (err, data) {
|
||||||
if (res.locals.isAPI) {
|
|
||||||
res.json(data);
|
|
||||||
} else {
|
|
||||||
res.render('home', data);
|
res.render('home', data);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -276,6 +276,10 @@ middleware.processRender = function(req, res, next) {
|
|||||||
fn = defaultFn;
|
fn = defaultFn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (res.locals.isAPI) {
|
||||||
|
return res.json(options);
|
||||||
|
}
|
||||||
|
|
||||||
render.call(self, template, options, function(err, str) {
|
render.call(self, template, options, function(err, str) {
|
||||||
if (res.locals.footer) {
|
if (res.locals.footer) {
|
||||||
str = str + res.locals.footer;
|
str = str + res.locals.footer;
|
||||||
|
|||||||
Reference in New Issue
Block a user