SORU
8 Ocak 2013, Salı


Python jinja2 steno koşullu

Bu var dediler

{% if files %}
    Update
{% else %}
    Continue
{% endif %}

PHP, diyelim ki, bir steno koşullu, gibi yazabilirim:

<?php echo $foo ? 'yes' : 'no'; ?>

Bu jinja2 bir şablon çalışması için tercüme edebilirim o zaman bir şekilde

'yes' if foo else 'no'

CEVAP
8 Ocak 2013, Salı


Evet, mümkün inline if-expressions kullanmak için:

{{ 'Update' if files else 'Continue' }}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • eurotuner

    eurotuner

    6 Mart 2006
  • Sergio Fernandez

    Sergio Ferna

    1 EKİM 2009
  • theatre2film

    theatre2film

    12 NİSAN 2006