use*_*943 3 node.js backbone.js handlebars.js
我试图使用NodeJS和Backbone渲染Handlebars模板.
到目前为止,我在HTML文件中完成的工作非常有效:
app.MyView = Backbone.View.extend({
...
render: function() {
var template = Handlebars.compile( $("#my-template").html());
this.$el.html( template(this.model.toJSON()) );
return this;
}
...
});
Run Code Online (Sandbox Code Playgroud)
在HTML中查看:
<script type="text/x-handlebars-template" id="my-template">
{{text}}
</script>
Run Code Online (Sandbox Code Playgroud)
但是,如果我将此视图放在Handlebars模板中,则它不起作用,因为NodeJS Handlebars编译器正在解释{{text}}.
尝试:
<script type="text/x-handlebars-template" id="my-template">
\{{text}}
</script>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1462 次 |
| 最近记录: |