I would like to mark a block of text inside an EJS template not to be touched by EJS during output generation. This block contains "EJS" tags because it is an underscore.js template which uses the same syntax.
Can I do this without changing the delimiters of either of the templating engines?
Don't do that, You'll be asking for a world of hurt when your future self comes back to this.
There isn't an escape for "ejs" like your asking but there are some close alternatives.
String.replace
to make your own escape syntax.var template = _.template('<%= $.a %> foo #%= something_else %>',
null, {variable: '$'});
var ejs = template({a: 'bar'}).replace(/#%/g, '<%');
var template = _.template('{{ $.a }} foo <%= something_else %>',
null, {
variable: '$',
interpolate: /\{\{(.+?)\}\}/g
});
var ejs = template({a: 'bar'});
var ejs_template = '<%= something_else %>';
var template = _.template('<%= $.a %> foo <%= $.ejs %>',
null, {variable: '$'});
var ejs = template({
a: 'bar',
ejs: ejs_template
});