I have a python dictionary:
settings = {
"foo" : "baz",
"hello" : "world"
}
This variable settings
is then available in the Jinja2 template.
I want to check if a key myProperty
exists in the settings
dict within my template, and if so take some action:
{% if settings.hasKey(myProperty) %}
takeSomeAction();
{% endif %}
What is the equivalent of hasKey
that I can use?
Like Mihai and karelv have noted, this works:
{% if 'blabla' in item %}
...
{% endif %}
I get a 'dict object' has no attribute 'blabla'
if I use {% if item.blabla %}
and item
does not contain a blabla
key