I would create a master template for generating other templates. The only method I found is this one:
var test_tpl_master = _.template(
"StackOverflow <%= type %> question number <%= num %>"
);
var test_tpl_1 = _.template(test_tpl_master({
"type": "good",
"num": "<%= num %>"
}));
var test_tpl_2 = _.template(test_tpl_master({
"type": "stupid",
"num": "<%= num %>"
}));
Is there not a more simple and elegant way?
You can create a function that will act as a proxy to your master and will fill the the variables you want.
For example, let's say you have
You can then create your subtemplates functions by
and use them as any other template :
And a demo http://jsfiddle.net/nikoshr/qshb1zrx/