javascript - Swig Templates List Item Number -
i can't figure out how print number of list item using swig templates. example( 1, 2, 3, 4, 5 ).
<ul> {% result in results %} <li> <span>item number: {{n}}</span> {{ result.title }} </li> {% endfor %} </ul>
you can find reply under “task #1” heading on page:
http://bits.shutterstock.com/2013/03/07/mustache-vs-swig-templating-shootout/specifically, within {% %}
tags in swig, have access variable called loop
, has index
property:
<ul> {% result in results %} <li> <span>item number: {{ loop.index }}</span> {{ result.title }} </li> {% endfor %} </ul>
see swig docs: http://paularmstrong.github.io/swig/docs/tags/#for
javascript templates swig-template
No comments:
Post a Comment