我正在与underscore.js和主干一起为一个应用程序创建一些视图。视图都有相同的前几行,但根据它们是哪种类型的子类而有所不同。是否有一种有效的方法来组合模板,这样我就可以有一个单一的“主”模板,并将其插入到所有其他模板中?
代码示例:
<script type="text/template" id="template-1">
{{ name }}
<span>{{ type }}</span>
<div>
<some view specific html>
</div>
</script>
<script type="text/template" id="template-2">
{{ name }}
<span>{{ type }}</span>
<div>
<some view specific html>
</div>
</script>发布于 2012-04-25 19:02:27
我认为有两种方法你可以采取:
https://stackoverflow.com/questions/10321486
复制相似问题