machty / emblem.js

Emblem.js - Ember-friendly, indented syntax alternative for Handlebars.js
http://emblemjs.com
MIT License
1.04k stars 81 forks source link

Getting index within Each Helper #161

Closed alexQueue closed 10 years ago

alexQueue commented 10 years ago

This works in Handlebars:

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

This fails in Emblem:

ul
  each App.things
    li {{@index}}

I get this error: Uncaught Error: Emblem syntax error, line 1: Expected BeginStatement or DEDENT but "=" found. =@index

Perhaps this is not an issue, but I thought Emblem was intended to behave functionally like Handlebars.

colinbellino commented 10 years ago

I'm having the same issue, were you able to get this to work ?

machty commented 10 years ago

Are you sure you're on the latest Emblem? This seems to work:

http://jsbin.com/ucanam/5701

colinbellino commented 10 years ago

So i did some digging and it turns out the problem come from a bug in the ember-template-compiler module that is used by ember-cli (via broccoli-emblem-compiler).

I found a solution to my problem (see below), thanks for your answer, it helped a lot ;)

If anyone else is having this issue, here is what i found :

ul
  each App.things
    li {{_view.contentIndex}}
machty commented 10 years ago

Doesn't seem like a bug/missing feature for this repo.

machty commented 10 years ago

Thanks @cbellino for digging in :)

dishcandanty commented 7 years ago

In case anyone runs into it today and finds this like I did:

each list as |item index|
      = index