I have the following loop in my jinja2 template
{% for item in list if item.author == 'bob' %}
I am trying to get the first 5 items who have bob as an author.
I tried doing
{% for item in list if item.author == 'bob' and loop.index <= 5 %}
but it returned an undefined error.
How to make it work?