question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting index within Each Helper

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
dishcandantycommented, Aug 10, 2017

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

each list as |item index|
      = index
0reactions
machtycommented, Jul 13, 2014

Thanks @cbellino for digging in 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get index in Handlebars each helper? - Stack Overflow
I'm using Handlebars for templating in my project. Is there a way to get the index of the current iteration of an "each"...
Read more >
Building a Handlebars "each with index" helper
Here's a super quick post about building a Handlebars helper in an Ember app for numbering lists in the context of an {{each}}...
Read more >
JavaScript : How to get index in Handlebars each helper?
JavaScript : How to get index in Handlebars each helper ? [ Gift : Animated Search Engine : https://bit.ly/AnimSearch ] JavaScript : How...
Read more >
Include index in each block helper, aka each_with_index #250
Seems like I get 'Cannot call method 'replace' of undefined' when trying to use it with that syntax. With the {{#each bar}} syntax,...
Read more >
Built-in Helpers - Handlebars
You can iterate over a list using the built-in each helper. Inside the block, you can use this to reference the element being...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found