handlerbar.js

handlerbar.js

Handlebars templates 像普通的html, 嵌入式的 handlebars 表达式.

<div class="entry">
  <h1>{{title}}</h1>
  <div class="body">
    {{body}}
  </div>
</div>

你可以用<脚本>标签的方式提供向浏览器提供一个模版。利用handlebars.compile编译JavaScript模板。

它采用预编译方式,This will result in a smaller required runtime library and significant savings from not having to compile the template in the browser. This can be especially important when working with mobile devices.

<script id="entry-template" type="text/x-handlebars-template">
  template content
</script>
var source   = $("#entry-template").html();
var template = Handlebars.compile(source);

。。。。。

原文地址:https://www.cnblogs.com/dingding0505/p/3724964.html