Handlebars.js返回一个空模板

时间:2015-03-14 06:05:42

标签: javascript html node.js handlebars.js koa

我正在使用Koa运行节点服务器并使用Handlebars进行模板化。我有以下模板:

<script id="side_item" type="text/x-handlebars-template">
    <li>
       <a href="{{this.route}}"><i class="{{this.icon}}"></i> {{this.name}}</a>
    </li>
</script>

我的javascript代码是:

var source = $("#side_item").html();
var template = Handlebars.compile(source);
 var html = template({
    route: "museum",
    icon: "fa fa-institution fa-fw",
    name: "Museum"
});

但我得到以下来源:

<script id="side_item" type="text/x-handlebars-template">
   <li>
      <a href=""><i class=""></i> </a>
   </li>
</script>

我假设将删除脚本标记并呈现完成的模板。是否有可能在把手看到它们之前删除表达式的括号?或者我如何编译模板有什么问题?我尽可能地在车把网站上关注这些例子。

0 个答案:

没有答案