我在ascx文件中有这样的把手脚本代码。
<script id="ex" type="text/x-handlebars-template">
{{#each model}}
{{#if condition}}
//Need to Break, Dont know how to do that
{{/if}}
{{/each}}
</script>
答案 0 :(得分:2)
只需将此对象传递给javascript函数,执行所需的逻辑并将其返回。
<script type= "text/javascript">
Handlebars.registerHelper("ifSet", function (model) {
var count = 0;
while (count < model.length) {
// if (logic Condition){
// return 'Success'; or Break;
// }
}
return;
});
</script>
<script id="ex" type="text/x-handlebars-template">
{{ifSet model}}
</script>