ember-cli支持Handlersars @vars in each helper(即@index,@ key,@ first,@ are)

jak*_*ake 6 javascript handlebars.js ember.js ember-cli

每当我有一个使用@vars变量(即@ index,@ key,@ first,@ pop)的Handelbars模板时,我就会在ember-cli中收到编译错误.(有关每个帮助程序中这些@vars变量的文档,请参阅http://handlebarsjs.com/#iteration.)下面是一个使用ember-cli构建的简单应用程序,只包含两个添加到程序中的文件:routes/application.js和templates/application.hbs.在这篇文章的底部是ember-cli给出的编译错误消息的屏幕截图.我的代码中有错误吗?或者这是我应该在github上报告的错误@ https://github.com/stefanpenner/ember-cli

路线/ application.js中

export default Ember.Route.extend({
    model: function() {
        return ['red', 'blue', 'green'];
    }
});
Run Code Online (Sandbox Code Playgroud)

模板/ application.hbs

{{#each model}}
  {{@index}}: {{this}}
{{/each}}
Run Code Online (Sandbox Code Playgroud)

ember-cli编译错误消息的屏幕截图: ember-cli编译错误消息的屏幕截图

以下是涉及的各种工具的版本:

  • ember-cli:0.0.40
  • 节点:0.10.30
  • npm:1.4.21
  • 把手:1.3.0
  • 恩伯:1.6.1

Kin*_*n2k 4

这确实与 ember-cli 无关。Ember Handlebars 不支持@keyword 项目。

  • 谢谢,这对我来说是新闻。您的评论帮助我找到了这篇相关文章:http://mozmonkey.com/2014/03/ember-getting-the-index-in-each-loops/ (2认同)