visionmedia/jade — pull request #1019 by svsool (2013-05-11 15:25:38+00:00)
Title: loop helper

now loop variable available in for,each loops

![2013-05-11 18 37 40](https://f.cloud.github.com/assets/1452141/491633/5fbe3c96-ba48-11e2-83c5-3f93d73a6274.png)

all is simple, I used literal @ for exposing loop length to loop helper, because it's very hard parse with regexp without marking it

some examples:

jade:
```jade
- length = 3
ul
for (var i = 0; i < @length; i++)
li(class=loop.first && 'active')
```

html:
```html

```

jade:
```jade
each user in ["Petya", "Masha", "Sveta"]
div #{user}
if (loop.first)
| - is man
if (loop.index == 2)
| - is girl
if (loop.last)
| - is girl
```

html:
```html

Petya- is man

Masha- is girl

Sveta- is girl
```

jade:
```jade
for (var i = 0; i < @5; i++)
div loop.index0, element № 3 expected, element № #{i}
- if (loop.index0 == 3)
| marked
```

html:
```html

element № 3 expected as marked, element № 0

element № 3 expected as marked, element № 1

element № 3 expected as marked, element № 2

element № 3 expected as marked, element № 3 marked

element № 3 expected as marked, element № 4

```