Подчеркивание шаблон не работает отладчик
// run with console open
//and paste following when you hit the debugger:
/*
_.templateSettings = {
interpolate: /\{\{(.+?)\}\}/g
};
var template = _.template("Hello {{ name }}!");
console.log(template({name: "Mustache"}))
*/
debugger
//should return:
//underscore-min.js:5Uncaught TypeError: Cannot read property 'call' of undefined
//out of debugger though, it works:
_.templateSettings = {
interpolate: /\{\{(.+?)\}\}/g
};
var template = _.template("Hello {{ name }}!");
console.log(template({name: "Mustache"}))
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
Я не могу запустить underscore's sample template код в отладчике (я хочу играть с фактическими данными в консоли).
- код в .js файл работает нормально. ✓
- вставляется в консоль после загрузки страницы. ✓
вставленный во время точки останова отладчика - не работает. ✘
_.templateSettings = { interpolate: /\{\{(.+?)\}\}/g } var template = _.template("Hello {{ name }}!"); template({name: "Mustache"});
Ошибка:
underscore.js:1461 Uncaught TypeError: Cannot read property 'call' of undefined
редактировать:
Ошибки на template({name: "Mustache"});
Line 1461 из Underscore версии 1.8.3:
var template = function(data) {
return render.call(this, data, _);
};
Какая версия подчеркивания? Какая строка в вставленном коде вызывает ошибку? Что находится в строке 1461 версии underscore.js, которую вы используете? –
Ответа на этот вопрос (see edit) – Ashbury
Где контрольная точка? Это внутри подчеркивание? –