Question: I am passing an array of objects to jQuery template (official `jquery-tmpl` plugin):

```
$("#itemTmpl").tmpl(items).appendTo("body");

<script id="itemTmpl" type="text/x-jquery-tmpl">
    <div class="item">Name: ${name}, Index: ${???}</div>
</script>

```

What is the easiest way to display item index in the template? Preferably without using separated external functions, without changing passed object structure, and without changing template structure (converting to `{{each}}`). Is there any built-in variable perhaps that stores current array index?

**UPDATE**
I created [a ticket](http://bugs.jquery.com/ticket/7137) proposing to expose array index to template item but it was closed as invalid...

Answer: 
Here's a cheezy hack:

```
${ _index === undefined && _index = 0, '' }
<strong>Item ${ index }:</strong> ${ content }
${ _index++, '' }

```
Easy way to do this using jQuery 1.6.4 or newer at least.

First as you'd expect iterate through a collection

```
{{each myListofStuff}}
Index: ${$this.index}
{{/each}}

```

Will do the trick!