【问题标题】:Ember.js and Yeoman, external template file insertionEmber.js 和 Yeoman,外部模板文件插入
【发布时间】:2012-11-28 22:46:30
【问题描述】:

我是一个使用 Ember.js 的新手,我今天才开始查找它。 我目前正在计划使用 Ember.js 和 Yeoman 开发一个 Phonegap 应用程序,并且在我对 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,现在我使用了 index.html 中所需的 application.js。

但是我如何告诉我的应用程序我需要在我的 index.html 中需要相关(与我的路由)模板才能将其插入 DOM 中?

我真的不想在一个 .html 文件中定义我的所有模板。

我一定是错过了什么……

谢谢!

【问题讨论】:

  • 这似乎部分与Yeoman and handlebars templates 重复。
  • 部分,是的,但我实际上说我使用 grunt-ember-handlebars 而不是 grunt-ember-templates 遵循了非常相似的过程。这是我不知道的下一步;)

标签: javascript cordova ember.js handlebars.js yeoman


【解决方案1】:

我实际上使用了这个脚本:https://stackoverflow.com/a/13474886/1345058,到目前为止似乎工作正常。

我可能会重新考虑。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-22
    • 2017-07-18
    • 2011-04-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多