I'd like to know if there is any solution to throw an error when a variable is not defined inside my template?
Example:
function hello() {
var data = { foo: 'hello' };
//data.bar is undefined, data.bar will be replaced by an empty string by underscore
var render = _.template('<p><%= data.foo %><%= data.bar %></p>', {data: data});
//Rendering okay? true|false
//if (render...)
}
I'd like to throw an error if the variable data.boo is not defined after the call of the _.template function. Do you have any idea if it's possible to do something like that? I checked the documentation and didn't find anything interesting unfortunately...
Thanks
data.foois undefined?