Home > Mobile >  How to Negate in this Jinja if condition?
How to Negate in this Jinja if condition?

Time:01-18

I have this in template:

{% if cell %}{% set cell = "b" %}{% endif %}

What is contradiction of above conditional?

This not works:

{% if !cell %}

CodePudding user response:

You might use not word, consider following simple example

import jinja2
template = jinja2.Template('cell {% if not cell %}negated{% endif %}')
print(template.render(cell=True))  # cell 
print(template.render(cell=False))  # cell negated
  • Related