jeudi 12 novembre 2015

@first not working with Ember.js

The version of Ember I am using uses a version of Handlebars that, in its release notes, claim to support @index and @first.

However, when I use these in my hbs files, I get the following error:

SyntaxError: Unexpected token ,

Now, with a little bit of research, for the @index portion,

{{_view.contentIndex}}

seems to render the index. However, I cannot use these in conditionals. What I need is a working version of :

{{#each array}}
 {{#if @first }}
  <!-- first element specific html -->
 {{else}}
  <!-- other html -->
 {{/if}}
{{/each}}

I have tried _view.first and also tried to use _view.contentIndex in a helper, but failed. Is there a workaround to this?

Aucun commentaire:

Enregistrer un commentaire