Template error update for underline 1.7

When updating my web application with underscores from 1.6 to 1.7, I get the following error: "The list is not defined." When using underscore 1.6, it works great. Any ideas?

//acquire the list template $.get('tpl/listTpl.html', function(templates) { //run underscore js on the list template and pass in the full collection of models var template = _.template(templates, {list:app.collections.list.models}); //load the underscore template into the DOM that.$el.html(template); 

});

+5
source share
1 answer

From 1.7.0 changelog :

Underline patterns no longer accept the initial data object. _.template always returns a function.

You will need to change your code to the following:

 $.get('tpl/listTpl.html', function(templates) { var template = _.template(templates); var result = template({list:app.collections.list.models}); that.$el.html(result); }); 
+16
source

Source: https://habr.com/ru/post/1201423/


All Articles