5 Aralık 2011, PAZARTESİ
birden çok koşul VARSA dal:
Açıklama eğer bir çubukla problem var gibi görünüyor.
{%if fields | length > 0 || trans_fields | length > 0 -%}
Hata:
Unexpected token "punctuation" of value "|" ("name" expected) in
Bu çalışmıyor neden anlamadım, eğer dal tüm boruları ile kaybedildi gibi.
Bu denedim :
{% set count1 = fields | length %}
{% set count2 = trans_fields | length %}
{%if count1 > 0 || count2 > 0 -%}
ama eğer o da başarısız.
Bu çalıştı:
{% set count1 = fields | length > 0 %}
{% set count2 = trans_fields | length > 0 %}
{%if count1 || count2 -%}
Ve hala aynı hata her zaman işe yaramıyor ...
Çok basit bir soru için bana yol: birden fazla hastalık VARSA Dal destekliyor mu ?
CEVAP
5 Aralık 2011, PAZARTESİ
Eğer doğru hatırlıyorsam ||
&&
operatörler desteği Dal yok ama or
and
sırasıyla kullanılacak gerektirir. Ayrıca parantez bu teknik olarak bir gereklilik değil, ancak iki ifade daha açık bir şekilde ifade etmek için kullanmak istiyorum.
{%if ( fields | length > 0 ) or ( trans_fields | length > 0 ) %}
İfadeler
Expressions can be used in {% blocks %} and ${ expressions }.
Operator Description
== Does the left expression equal the right expression?
Convert both arguments into a number and add them.
- Convert both arguments into a number and substract them.
* Convert both arguments into a number and multiply them.
/ Convert both arguments into a number and divide them.
% Convert both arguments into a number and calculate the rest of the integer division.
~ Convert both arguments into a string and concatenate them.
or True if the left or the right expression is true.
and True if the left and the right expression is true.
not Negate the expression.
For more complex operations, it may be best to wrap individual expressions in parentheses to avoid confusion:
{% if (foo and bar) or (fizz and (foo bar == 3)) %}
Bunu Paylaş:
Birden çok farklı HTML elemanları aynı...
En iyi yolu birden fazla koşul ile ifa...
Javascript birden fazla koşul deyimi i...
Eğer birden çok dize başka bir dize va...
Nasıl bir kabuk içinde birden fazla ko...