【发布时间】:2012-05-18 05:03:49
【问题描述】:
我正在尝试使用 javascript 模板
<script type="text/x-tmpl" id="tmpl-demo">
<h3>{%=o.title%}</h3>
<p>Released under the
<a href="{%=o.license.url%}">{%=o.license.name%}</a>.</p>
</script>
问题是 - 我想在我的 JS 文件中包含这个?我将如何使用模板但在我的 JS 文件中我假设我不能使用 <script> 标记?
目前,我正在做类似的事情:
myFunction(id) {
return "<div>" + id + "</div>";
}
我想将其转换为模板?
【问题讨论】:
-
另外 - 有人能建议为什么第二种方法 - 使用
return- 不好吗?
标签: javascript jquery templates