我正在尝试使用 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;
}
...
});
在 HTML 中查看:
<script type="text/x-handlebars-template" id="my-template">
{{text}}
</script>
但是,如果我将这个 View 放在 Handlebars 模板中,它就不起作用,因为 {{text}} 正在被 NodeJS Handlebars 编译器解释。
最佳答案
尝试:
<script type="text/x-handlebars-template" id="my-template">
\{{text}}
</script>
关于node.js - Handlebars 内的 Handlebars 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19386823/