可用的 Liquid 條件運算子

注意

自 2022 年 10 月 12 日起,Power Apps 入口網站為 Power Pages。 其他資訊:Microsoft Power Pages 現在已推出 (部落格)
我們很快就會遷移並將 Power Apps 入口網站文件與 Power Pages 文件併合。

在條件陳述式中使用時 (ifunless),某些 Liquid 值會視為 true,有些則視為 false。

在 Liquid 中,null 和布林值 false 會視為 false,其他項目則視為 true。 空字串、空陣列等會視為 true。 例如,

{% assign empty_string = "" %}
{% if empty_string %}
<p>This will render.</p>
{% endif %}

必要時,您可以測試空字串和陣列,使用特殊空值。

{% unless page.title == empty %}
<h1>{{ page.title }}</h1>
{% endunless %}

您也可以測試 Liquid 類型Liquid 類型,或 Liquid 類型 的大小,使用特殊大小屬性。

{% if page.children.size > 0 %}
<ul>
{% for child in page.children %}
<li>{{ child.title }}</li>
{% endfor %}
</ul>
{% endif %}

總結

運算子
×
×
Null ×
String ×
空字串 ×
0 ×
1, 3.14 ×
陣列或字典 ×
空陣列或字典 ×
Object ×

請參閱

使用網站範本儲存來源內容
了解 Liquid 運算子
Liquid 類型
Liquid 物件
Liquid 標籤
Liquid 篩選

注意

是否能請您告知您偏好的慣用文件語言? 請填寫問卷。 (請注意,本問卷為英文版)

完成問卷大約需要七分鐘。 本問卷將不會收集個人資料 (隱私權聲明)。