Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{{@index}} not working (generates a syntax error) #607

Closed
itsjavi opened this issue Aug 25, 2013 · 9 comments
Closed

{{@index}} not working (generates a syntax error) #607

itsjavi opened this issue Aug 25, 2013 · 9 comments
Labels

Comments

@itsjavi
Copy link

itsjavi commented Aug 25, 2013

Hi, I've tried to output the index of an each loop, as documented in the handlebarsjs.com webpage, but it is not working. It fires a syntax error.

I've used the starter kit code, and only modified some lines:

  <script type="text/x-handlebars" data-template-name="index">
    <ul>
    {{#each model}}
      <li>{{@index}} : {{this}}</li>
    {{/each}}
    </ul>
  </script>

Browser used: Chrome 29 (latest), OSX Mountain Lion

This produces this error:

captura de pantalla 2013-08-25 a la s 17 46 47

Any clue of what's happening? Is a bug? Am I doing something wrong? Thanks

@kpdecker
Copy link
Collaborator

At first glance it appears that that should work. Can you create a jsfiddle demonstrating the issue?

@itsjavi
Copy link
Author

itsjavi commented Aug 27, 2013

Here it is http://jsfiddle.net/SRKD5/1/
In latest Firefox doesn't work either

@kpdecker
Copy link
Collaborator

Somehow this is causing an empty field for the @index lookup

  options = {hash:{},contexts:[depth0],types:["DATA"],hashContexts:hashContexts,hashTypes:hashTypes,data:data};
  data.buffer.push(escapeExpression(((stack1 = helpers._triageMustache || depth0._triageMustache),stack1 ? stack1.call(depth0, , options) : helperMissing.call(depth0, "_triageMustache", , options))));
  data.buffer.push(" ");

I'm not clear if this is related to the handlebars library directly or an interaction between handlebars and the overrides that are implemented in ember.

@kpdecker
Copy link
Collaborator

/cc @wagenet

@itsjavi
Copy link
Author

itsjavi commented Aug 30, 2013

thanks @kpdecker I tried to figure out looking at the handlebars code, but cannot find a solution.

@itsjavi
Copy link
Author

itsjavi commented Sep 1, 2013

Issue referenced in emberjs/ember.js#3030

@itsjavi itsjavi closed this as completed Sep 1, 2013
@itsjavi itsjavi reopened this Sep 1, 2013
@itsjavi
Copy link
Author

itsjavi commented Sep 1, 2013

I've found the solution by using {{_view.contentIndex}}
http://jsfiddle.net/SRKD5/2/

@itsjavi itsjavi closed this as completed Sep 1, 2013
@tirana
Copy link

tirana commented Dec 5, 2013

What should I do for multiply each blocks?
{{#each child1 in model}}
{{#each child2 in child1.children}}
{{??parent??contentIndex}} {{_view.contentIndex}} : {{child2}}
{{/each}}
{{/each}}

@kpdecker
Copy link
Collaborator

kpdecker commented Jan 7, 2014

I strongly suspect that this is the same issue as #699.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants