Ven*_*h K 5 html handlebars.js
我在我的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>
Run Code Online (Sandbox Code Playgroud)
只需将此对象传递给 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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4130 次 |
| 最近记录: |