Permalink
Browse files

Support view locals

  • Loading branch information...
1 parent a95e26d commit 58540a5e1ce019b77415d99f2664df8dcd6b9e9f @Qard committed Jan 25, 2012
Showing with 9 additions and 0 deletions.
  1. +9 −0 lib/index.js
View
@@ -164,6 +164,15 @@ Crsh.middleware = function (path, blocks) {
// Expose named list to req object
return function (req, res, next) {
req.crsh = list
+
+ // Expose named list to views, if possible
+ if (typeof res.local === 'function') {
+ for (var i in list) {
+ res.local('crsh_'+i, list[i])
+ }
+ }
+
+ // Continue
next()
}
}

0 comments on commit 58540a5

Please sign in to comment.