express-prefixed-roots-view

Alternative View class, provides another lookup method based on mappings prefix: dir

npm install express-prefixed-roots-view
7 downloads in the last day
17 downloads in the last week
116 downloads in the last month

express-prefixed-roots-view

Alternative View class, provides another lookup method based on mappings prefix: dir.

Now, you can use multiple view dirs with express and use prefixes to access templates in it.

Compatible with express 3.x. Tested with express 3.2.x.

You can use npm for install the last stable version:

$ npm install express-prefixed-roots-view

Usage:

app.set('view', require('express-prefixed-roots-view'));
app.set('views', {
  '': __dirname + '/views',
  'module': __dirname + '/module/views',
  'module2': __dirname + '/module2/views'
});

Now, when you call res.render('index'), it only tries to render '/views/index'.

When your call res.render('module/index'), it tries to render '/views/module/index', if such file does not exists, it tries to render '/module/views/index'.

So, you can override templates, provided with modules.

npm loves you