In client side ejs I use [% code %] instead of <% code %> to mark ejs code, but I would like to do the same on the server side with express. On the client side I would do something like var template = new EJS({text: template_src, type:'['});
Here is my node code:
app.set('view engine', 'ejs');
app.register('.html', require('ejs'));
app.get('/', function(req, res){
res.render('index.html', { title: 'My Site' });
});
Where do you set the "type" paramater so I can change this option
From the EJS github page:
Custom tags can also be applied globally:
var ejs = require('ejs'); ejs.open = '{{'; ejs.close = '}}';
The only thing you need to do it copy these lines at the beginning of your Express app and that's that - the change is applied globally (change the open and close tag to whatever you want).
Update for most recent version as of July 20, 2016
As of most recent versions of EJS, it is not possible to use custom tags anymore (see https://github.com/mde/ejs/issues/55 ). All you can do is change delimiters from default % to others ( delimiter option ).
There are talks about re-enabling this. See https://github.com/mde/ejs/issues/88 and https://github.com/mde/ejs/issues/115
If you use express:
app.set('view options', {
open: '{{',
close: '}}'
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With