python - How to tell If Expression to return an empty string in Jinja2 -


i have input tag of date type value want set '' if dictionary doesn't contain isodate. if dictionary contain isodate, formats isodate string displayed correctly:

<input type="date" value="{% '' if mydict['date']=='' else mydict['date'].strftime('%y-%m-%d')%}"> 

but error message:

templatesyntaxerror: tag name expected 

i appreciate advice.

it should double curly braces {{ your_expression }}

<input type="date" value="{{ '' if dict['date']=='' else dict['date'].strftime('%y-%m-%d') }}"> 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -