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);

。。。。。

posted on 2014-05-13 10:35  TouTou9055  阅读(415)  评论(0编辑  收藏  举报

导航