ember-cli 支持每个助手中的 Handlebars @vars(即 @index、@key、@first、@last) [英] ember-cli support for Handlebars @vars in each helper (i.e., @index, @key, @first, @last)

查看:24
本文介绍了ember-cli 支持每个助手中的 Handlebars @vars(即 @index、@key、@first、@last)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am getting a compilation error in ember-cli whenever I have a Handelbars template that uses @vars variables (i.e., @index, @key, @first, @last) inside of the each helper. (See http://handlebarsjs.com/#iteration for documentation on these @vars variables inside the each helper.) Below is a simple application built using ember-cli and containing only two files added to the program: routes/application.js and templates/application.hbs. At the bottom of this post is a screenshot of the compilation error message given by ember-cli. Is there an error in my code? Or is this a bug I should report on github @ https://github.com/stefanpenner/ember-cli?

路由/application.js

routes/application.js

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

模板/application.hbs

templates/application.hbs

{{#each model}}
  {{@index}}: {{this}}
{{/each}}

ember-cli 编译错误信息截图:

Screenshot of ember-cli compilation error message:

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

Here are the versions of the various tools involved:

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

推荐答案

那确实与 ember-cli 无关.Ember Handlebars 不支持 @keyword 项.

That really isn't related to ember-cli. Ember Handlebars doesn't support the @keyword items.

这篇关于ember-cli 支持每个助手中的 Handlebars @vars(即 @index、@key、@first、@last)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆