Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Documentation for the For tag incorrectly has forloop.index and forloop.key as tags instead of variables #42

Closed
imbcmdth opened this Issue · 0 comments

2 participants

@imbcmdth

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 %}<ul>{% endif %}
    <li>{% forloop.index %} - {% forloop.key %}: {{ x }}</li>
    {% if forloop.last %}</ul>{% 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 %}<ul>{% endif %}
    <li>{{ forloop.index }} - {{ forloop.key }}: {{ x }}</li>
    {% if forloop.last %}</ul>{% endif %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.