Jinja allows me to do
{% for item in all_items %} {{ item }} {% endfor %}
but I\'d like to be able to only take the first n items;
You can use normal python slice syntax.
>>> import jinja2 >>> t = jinja2.Template("{% for i in items[:3] %}{{ i }}\n{% endfor %}") >>> items = range(10) >>> print(t.render(items=items)) 0 1 2