Skip to content
Browse files

pathHandler should specify the whole request processing logic

  • Loading branch information...
1 parent 3e5a47d commit db691b64eecf98c4acf2f7e8fd1f55cf0d06c9d7 @eldargab committed May 21, 2012
Showing with 11 additions and 7 deletions.
  1. +11 −7 lib/index.js
View
18 lib/index.js
@@ -10,14 +10,18 @@ Views.PathLookup = require('./path-lookup')
function Views (opts) {
opts = opts || {}
opts.root = opts.root || process.cwd()
- opts.pathHandler = opts.pathHandler || Views.Render(function (ext) {
- return opts.engine
- ? opts.engine(ext)
- : Views.engine(ext, opts)
- })
- return Views.Middleware(opts.root, Views.PathLookup(function (path, req, res, next) {
- opts.pathHandler(path, req, res, next)
+
+ opts.engine = opts.engine || function (ext) {
+ return Views.engine(ext, opts)
+ }
+
+ opts.pathHandler = opts.pathHandler || Views.PathLookup(Views.Render(function (ext) {
+ return opts.engine(ext)
}))
+
+ return Views.Middleware(opts.root, function (path, req, res, next) {
+ opts.pathHandler(path, req, res, next)
+ })
}
Views.engine = function engine (ext, opts) {

0 comments on commit db691b6

Please sign in to comment.
Something went wrong with that request. Please try again.