jinja2 first x items in for ... if loop jinja2 first x items in for ... if loop flask flask

jinja2 first x items in for ... if loop


EDIT:

you can simply nest the expressions?, i.e.

{% for item in list if item.author == 'bob' %}    {% if loop.index <= 5 %}       do something    {% endif %}{% endfor %}


to skip the first x elements you can

{% for category in categories[x:] %}

with all the expressions you can use for the regular lists


You can also use

{% for item in list[0:6] %}