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

问题描述

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



routes / application.js

 导出默认Ember.Route.extend({
model:function(){
return ['red','blue','green'];
}
});

templates / application.hbs

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

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



以下是各种工具的版本:




  • ember-cli:0.0.40

  • 节点:0.10.30

  • npm: 1.4.21

  • Handlebars:1.3.0

  • Ember:1.6.1

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


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?

routes/application.js

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

templates/application.hbs

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

Screenshot of ember-cli compilation error message:

Here are the versions of the various tools involved:

  • ember-cli: 0.0.40
  • node: 0.10.30
  • npm: 1.4.21
  • Handlebars: 1.3.0
  • Ember: 1.6.1

解决方案

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

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

11-01 19:43