From faf3de7e275bd6db6c94ae59c5c5b2129759ddfb Mon Sep 17 00:00:00 2001 From: psychobunny Date: Sun, 9 Mar 2014 19:54:16 -0400 Subject: [PATCH] added a check for res.locals.isAPI inside res.render, instead of doing it all over the place in code --- src/controllers/index.js | 6 +----- src/middleware/middleware.js | 4 ++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/controllers/index.js b/src/controllers/index.js index f62b0e7d10..f691204aa7 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -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); - } + res.render('home', data); }); }; diff --git a/src/middleware/middleware.js b/src/middleware/middleware.js index 2944e6f0e0..703008cab9 100644 --- a/src/middleware/middleware.js +++ b/src/middleware/middleware.js @@ -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;