I want to change default Swig tagControls {% ... %} to {? ... ?} I am using sails.js framework.
I add to config folder swig.js file, which contains:
module.exports.swig = {
SwigOpts: {
'tagControls': ['{?', '?}']
}
};
But it doesn't work, view in the browser look like this:
{? for user in users ?}
{? user.email ?}
{? endfor ?}
So, tags wasn't interpreted. Is my config file wrong? Standard tags {% ... &} works fine.
Something like this should work: in your config/views.js
engine: {
ext: 'swig', // Or `html`, whatever you are using
fn: function (pathName, locals, cb) {
var swig = require('swig');
swig.setDefaults({tagControls: ['{?', '?}']});
return swig.renderFile(pathName, locals, cb);
}
},
As for the config/swig.js
and module.exports.swig
, I don't think it's being processed automatically.