Feature request: null-coalescing operator
xahon opened this issue · comments
I need something like {{ data.types[sometype].mapping }}
and "sometype" might not be in dictionary "data.types", I need then a fallback to some common type. I tried {{ data.types[sometype].mapping if data.types[sometype] is not None else "CommonType" }}
and this doesn't work for me
jinja2.exceptions.TemplateRuntimeError: No test named 'None' found.
Would be cool to have {{ data?.types?[sometype]?.mapping || "CommonType" }}
See also https://peps.python.org/pep-0505/