SIUV
SIUV

Reputation: 181

How to check if a variable is a dictionary in jinja

set x = {'a':1}

how to find out if x is a dictionary in jinja? I tried to say if iterable but that can't differentiate between list, string, or dictionary. I want to know if a variable is a dictionary.

Upvotes: 7

Views: 5396

Answers (1)

dorancemc
dorancemc

Reputation: 163

With mapping filter, like

{% if x is mapping %} 
do something 
{% endif %}

Upvotes: 8

Related Questions