From bb3ee6d8be6da257e963bdd439f2c76de3eb8ac1 Mon Sep 17 00:00:00 2001 From: Samuel Mendenhall Date: Wed, 24 Jun 2015 08:07:15 -0400 Subject: [PATCH 1/2] Allowing options.locals to be specified to pass in parameters for view engines --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index ad3fc83..6dfd4f3 100644 --- a/index.js +++ b/index.js @@ -84,7 +84,7 @@ module.exports = function (options) { .catch(onFailedToRender); function onRendered(renderResult) { - var locals = {}; + var locals = options.locals || {}; locals[options.body || 'body'] = renderResult.htmlBody.trim(); locals[options.state || 'state'] = renderResult.htmlState.trim(); @@ -122,4 +122,4 @@ function tryRequire(dep) { } catch (e) { return require(dep); } -} \ No newline at end of file +} From 3cd071dc77e881c15b9c9e5372c634fda54b25fc Mon Sep 17 00:00:00 2001 From: Samuel Mendenhall Date: Fri, 26 Jun 2015 17:54:19 -0400 Subject: [PATCH 2/2] Adding the option to pass in a blacklist of regular expressions to ignore urls such as apis --- index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.js b/index.js index 6dfd4f3..4103c1e 100644 --- a/index.js +++ b/index.js @@ -69,6 +69,14 @@ module.exports = function (options) { return next(); } + if (options.blacklist) { + var blacklistMatched = false; + options.blacklist.forEach(function(re){ + if (re.test(req.url)) blacklistMatched = true; + }); + if (blacklistMatched) return next(); + } + router.run(function (Handler, state) { var app = new options.application({ req: req,