我是 Ember.js 的新手,我今天才开始查找它。 我目前计划使用 Ember.js 和 Yeoman 开发一个 Phonegap 应用程序,当我制作原型(prototype)并研究 Ember.js 框架时,我想知道:
如何在 index.html 中使用外部模板文件?在我看到的每个教程、帖子、指南或文档中,index.html 似乎都包含所有模板,格式为
<script data-template-name="my_template_name" type="text/x-handlebars">
{{my_handlebar_variable_content}}
</script>
等等……
但是当我使用 Yeoman 创建应用程序时,它会生成一个脚本/模板文件夹,其中包含所有 template.handlebars
模板文件。
我如何使用它们?我的意思是,我想,只要需要它们,它们就应该在 index.html 中被要求,但我该怎么做呢? 我已按照此说明进行操作 https://github.com/yeoman/yeoman/issues/455#issuecomment-8598553我现在有一个 application.js,我在 index.html 中需要它。
但是我如何告诉我的应用程序我需要在我的 index.html 中要求相关的(到我的路线)模板才能将其插入到 DOM 中?
我真的不希望所有模板都定义在一个 .html 文件中。
我一定是漏掉了什么……
谢谢!
最佳答案
我实际上使用了这个脚本:https://stackoverflow.com/a/13474886/1345058到目前为止似乎工作正常。
我可能会回来的。
关于javascript - Ember.js 和 Yeoman,外部模板文件插入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13615798/