jimsynz / hamlbars

Some extensions to HAML to allow generation of Handlebars templates.
https://github.com/jamesotron/hamlbars.git
MIT License
179 stars 43 forks source link

How to represent @index variable in the handlebars each loop. #60

Closed shishirmk closed 10 years ago

shishirmk commented 10 years ago

I am planning to use the "@index" used in the first answer to the question in this page http://stackoverflow.com/questions/11884960/how-to-get-index-in-handlebars-each-helper

I get the unexpected token error. So how do i represent that?

jimsynz commented 10 years ago

have you tried =hb '@index' ?

shishirmk commented 10 years ago

Yes i have tried it. I got an error Uncaught SyntaxError: Unexpected token , Some people have reported this error in the stackoverflow answer comments.

jimsynz commented 10 years ago

This is a problem with handlebars.js not hamlbars:

Using the following hamlbars:

= hb 'each widget' do
  =hb '@index'

generates:

{{#each widget}}{{@index}}{{/each}}

I suggest you raise an issue on barber or handlebars.

Cheers.

shishirmk commented 10 years ago

@jamesotron Thanks for taking a look at it