Logic

Sometimes, performing a single comparison operation on its own is not enough—perhaps we might want to perform an action if two comparisons evaluate to true at the same time. Alternatively, we might want to perform an operation only if a comparison is not true. Logic in Jinja2 helps group two or more comparisons together, allowing for the formation of complex conditions from simple comparisons. Each comparison is referred to as an operand, and the logic that's used to bind these together into complex conditionals is given in the following list: