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: 
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!
There is no easily accessible index. There is a key that is appended to each item.

```
<div class="item" jQuery1287500528620="1">

```

This key is accessible through jquery. So you can do something like 

```
$(".item").each(function () {
                var theTemplate = $(this).tmplItem();
                $(this).append("Index: " + theTemplate.key);
            });

```

But that's not what you wanted. I don't think what you wanted is possible. The ${$item} object is supposed to represent the tmplItem() method, but it doesn't provide a value for `${$item.key}.` Using `${$.tmplItem().key}` produces 0 for each row.

So the answer to your question is..... No.