jinja2 if else
Template Designer Documentation — Jinja2 Documentation (2.8-dev)
模板设计者文档 — Jinja2 2.7 documentation
最后用:
/Users/crifan/dev/dev_root/daryun/SIPEvents/sourcecode/sipevents/sipevents/views.py
@app.template_filter(‘event_has_expired’) def _jinja2_filter_event_has_expired(curEvent): “””check wheter event has expired.””” gLog.debug(“curEvent=%s”, curEvent) curDatetime = datetime.now() eventEndDate = curEvent.end_date hasExpired = False if curDatetime > eventEndDate : hasExpired = True gLog.debug(“curDatetime=%s, eventEndDate=%s -> hasExpired=%s”, curDatetime, eventEndDate, hasExpired) return hasExpired |
/Users/crifan/dev/dev_root/daryun/SIPEvents/sourcecode/sipevents/sipevents/templates/discoverEvent.html
{% if publicEvent | event_has_expired %} <img class=”al-over” src=”{{ url_for(‘static’, filename=’img/over.png’) }}”> {% endif %} |
即可。
转载请注明:在路上 » [已解决]jinja中的if else的判断语句