pallets / jinja

A very fast and expressive template engine.

Home Page:https://jinja.palletsprojects.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: null-coalescing operator

xahon opened this issue · comments

commented

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" }}