我根据设置会话(用户已登录)的条件从 handlebars
帮助函数动态返回以下代码
thumbsHelper: (id, reviewLiked, reviewDisliked) => {
console.log( id, reviewLiked, reviewDisliked );
if (global.sessions) {
return(
`<div class = "div-1-${ id }">
<div class="comments__actions">
<div class="comments__rate">
<button class = "up" onclick = "ajaxHelper(${ id }, 'up')" type = "button"><i class="icon ion-md-thumbs-up"></i> ${ reviewLiked } </button>
<button class = "down" onclick = "ajaxHelper(${ id }, 'down')" type = "button"> ${ reviewDisliked } <i class="icon ion-md-thumbs-down"></i></button>
</div>
</div>
</div>`
);
}
}
另一方面,在我的把手文件中,我这样做(调用上面的函数):
{{#thumbsHelper _id reviewLiked reviewDisliked}} {{/thumbsHelper}}
当我将车把文件中返回的代码硬编码为 HTML 时,它工作正常,但是当我从我的辅助函数文件(即 JavaScript)动态返回它时,Chrome 在这段代码中给了我上面提到的语法错误: class="icon ion-md-thumbs-up"></i>
我做错了什么?