Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

how to get the index within a loop? #59

Closed
dcsan opened this issue Aug 15, 2014 · 3 comments
Closed

how to get the index within a loop? #59

dcsan opened this issue Aug 15, 2014 · 3 comments

Comments

@dcsan
Copy link

dcsan commented Aug 15, 2014

within a loop, how do find out the index?
apparently its available as @index in handlebars, but that doesn't seem to work with meteor-jade.

handlebars-lang/handlebars.js#250 (comment)

I tried a few things:

each examples
  p {{this.index}}: {{this}}


  p {{@index}}   // fails  Expected IDENTIFIER

is there a way to fallback to using handlebars syntax with meteor-Jade templates?
eg

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

jade itself has index but i couldn't get that syntax to work either:

each name, i in names
  li #{i+1}: #{name}

examples here: http://technotip.com/3746/loops-and-conditions-in-jade-node-js/

@mquandalle mquandalle added question and removed bug labels Aug 17, 2014
@Gaelan
Copy link

Gaelan commented Aug 30, 2014

Also, keep in mind that Spacebars (meteor's default) != Handlebars, though the two are very similar. Spacebars might not support @index.

@dweldon
Copy link

dweldon commented Aug 31, 2014

I don't think this has been implemented in spacebars yet. For now, you can use this solution.

@mquandalle
Copy link
Owner

I'm closing this, because it's a Blaze feature, not meteor-jade.

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

No branches or pull requests

4 participants