您好我是车把的新手,我正试图通过我在车把上制作的自定义帮手来获取user_id,但我得到了例外,请帮忙。
注册助手
Handlebars.registerHelper('getSessionValue', function (keyValue) {
debugger;
var out = '';
$.ajax({
url: "/getSession",
method: 'post',
async: true,
dataType: json,
success :function(result){
out = result['user_id'];
}
});
return out;
});
hanldebar模板代码snipet
{{#getSessionValue}}
编译模板时出现错误
usr/local/lib/node_modules/handlebars/dist/cjs/handlebars/compiler/helpers.js:15
throw new Exception(mustache.sexpr.id.original + ' doesn\'t match ' + clos
^
Error: getSessionValue doesn't match if - 87:14
at new Error (<anonymous>)
at Error.Exception (/usr/local/lib/node_modules/handlebars/dist/cjs/handlebars/exception.js:13:41)
at Object.prepareBlock (/usr/local/lib/node_modules/handlebars/dist/cjs/handlebars/compiler/helpers.js:15:11)
at Object.anonymous (/usr/local/lib/node_modules/handlebars/dist/cjs/handlebars/compiler/parser.js:35:21)
at Object.parse (/usr/local/lib/node_modules/handlebars/dist/cjs/handlebars/compiler/parser.js:190:36)
at HandlebarsEnvironment.parse (/usr/local/lib/node_modules/handlebars/dist/cjs/handlebars/compiler/base.js:18:17)
at precompile (/usr/local/lib/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:389:17)
at HandlebarsEnvironment.hb.precompile (/usr/local/lib/node_modules/handlebars/dist/cjs/handlebars.js:22:12)
at processTemplate (/usr/local/lib/node_modules/handlebars/lib/precompiler.js:109:80)
at /usr/local/lib/node_modules/handlebars/lib/precompiler.js:115:5