handlerbar.js

handlerbar.jshtml

Handlebars templates 像普通的html, 嵌入式的 handlebars 表達式.瀏覽器

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

你能夠用<腳本>標籤的方式提供向瀏覽器提供一個模版。利用handlebars.compile編譯JavaScript模板。ui

它採用預編譯方式,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.spa

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

。。。。。code

相關文章
相關標籤/搜索