How to test for a List in Jinja2?

Viewed 46671

As far as I can see, there is no way to test if an object is a List instance in Jinja2.

Is that correct and has anyone implemented a custom test/extension in Jinja2?

5 Answers

Iterable return True also on dict. Try this:

{% if var.__class__.__name__ == 'list' %}
Related