Express
In vanilla Express.js, the following code works well.
var app = require('express')(); app.get('/jade', function(req, res) { res.render('slash.jade'); }); app.get('/ejs', function(req, res) { res.render('slash.ejs'); }); app.listen(1338);
As long as modules are present in node_modules , both templates are displayed by their respective engines.
You can also specify the default engine:
app.set('view engine', 'haml'); app.get('/', function(req, res) { res.render('slash');
In Express, the default view engine is used only when the extension is not specified .
Sails
In Sails.js, it seems that the specified config/view.js is the only one used in it.
If I try to specify the extension directly, I get the following error:
error: Ignoring attempt to bind route (/barn) to unknown view: barn.jade
Can I use different viewing mechanisms without a lot of voodoo in Sails?
source share