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 proposing to expose array index to template item but it was closed as invalid...