I'm trying to generate a JSP page, and since the template delimiters used by JSP's are the same as the ones used by underscore.
looking at the docs --> https://github.com/gruntjs/grunt/wiki/grunt.template#wiki-grunt-template-setDelimiters i can see they have a function for that
grunt.template.addDelimiters(name, opener, closer)
Two questions:
grunt.template.process() ( i have more than one, and for other non .jsp templates, the default delimiters are fine ) ?Any help is appreciated. Thanks.
from the documentation for grunt.template.process:
The default template delimiters are <% %> but if options.delimiters is set to a custom delimiter name, those template delimiters will be used instead.
that basically would mean that you can call grunt.template.process with the name of the delimiter you added before.
e.g. if you want to use square-brackets as delimiters in one processing step that should do the job:
// first add the new delimiters which you want to use
grunt.template.addDelimiters('square-brackets', '[', ']');
// and use it
grunt.template.process(template, {delimiters: 'square-brackets'});
// and use it with the default delimiters (named 'config')
grunt.template.process(template);
I have exactly the same issue. JSP uses <%= %> tags for its replacement which are also used by grunt. Added a line to overwrite the default setting applied in "https://github.com/gruntjs/grunt/blob/master/lib/grunt/template.js"
This worked for me:
// REPLACE the default 'config' delimiters
grunt.template.addDelimiters('config', '{%', '%}');
grunt.initConfig(
{ .... });
The delimiter name 'config' must match exactly.