paularmstrong/swig — Issue #42: Documentation for the For tag incorrectly has forloop.index and forloop.key as tags instead of variables
Author: imbcmdth
Created: 2012-02-05 04:02:35+00:00
State: open

The documentation available at: https://github.com/paularmstrong/swig/blob/master/docs/tags.md#for has the following example:

{% for x in y %}
{% if forloop.first %}

{% endif %}

{% forloop.index %} - {% forloop.key %}: {{ x }}

{% if forloop.last %}

{% endif %}
{% endfor %}

Which when used in node.js triggers the error:

Unknown logic tag at line X: "forloop.index"

Both forloop.key and forloop.index are *variables* NOT *tags* and the correct usage is:

{% for x in y %}
{% if forloop.first %}

{% endif %}

{{ forloop.index }} - {{ forloop.key }}: {{ x }}

{% if forloop.last %}

{% endif %}
{% endfor %}