【发布时间】:2013-04-08 19:42:06
【问题描述】:
我正在使用 grunt-ember-templates 预编译我的模板。正如预期的那样,该工具将我的模板放入Ember.TEMPLATES 数组中。我正在微调grunt-ember-templates 的配置。为此,我想知道 Ember.TEMPLATES 数组中的预期键是什么。假设我有这个模板:
<script type="text/x-handlebars" data-template-name="phones/index">
....
</script>
目前我在一个名为app/templates/phones_index.hbs 的文件中拥有这个模板,而grunt-ember-templates 正在将预编译的模板放入Ember.TEMPLATES["app/templates/phones_index"],但这是错误的。
data-template-name="phones/index" 的预期密钥是什么?
【问题讨论】:
-
我相信你应该编译
app/templates目录的内容,忽略文件名中的目录段,这样你就不会把它翻译成模板名。理想情况下,phones/index.hbs应转换为App.TEMPLATES["phones/index"]。请注意,_用于部分模板(例如:phones/_form.hbs用于链接到电话资源的通用表单),因此在部分模板以外的模板中使用它可能不是一个好主意。我不是 Grunt 的最佳人选,所以我真的不知道你应该怎么做。
标签: ember.js gruntjs grunt-ember-templates