可用的 Liquid 類型

注意

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

Liquid 物件可傳回七種基本類型之一:字串數字布林值陣列字典日期時間Null。 Liquid 變數可使用 assigncapture 標籤初始化。

字串

字串可藉由在單引號或雙引號中包裝文字的方式宣告。

{% assign string_a = "Hello World!" %}

{% assign string_b = 'Single quotes work too.' %}

使用 size 屬性取得字串中的字元數。

{{ string_a.size }} <!-- Output: 12 -->

編號

數字可以是整數或浮點。

{% assign pi = 3.14 %}

{% if page.title.size > 100 %}

This page has a long title.

{% endif %}

布林值

布林值是 true 或 false。

{% assign x = true %}

{% assign y = false %}

{% if x %}

This will be rendered, because x is true.

{% endif %}

陣列

陣列會保存任何類型的值清單。 您可以使用 [ ] 依 (從零開始的) 索引存取特定項目、使用 for tag 反覆查詢,以及使用 size 屬性取得陣列中的項目數。

{% for view in entitylist.views %}

{{ view.name }}

{% endfor %}

{{ entitylist.views[0] }}

{% if entitylist.views.size > 0 %}

This list has {{ entitylist.views.size }} views.

{% endif %}

Dictionary

字典可保存值的集合,可藉由字串索引鍵存取這些值。 您可以使用 [ ] 依字串索引鍵存取特定項目、使用 for tag 反覆查詢,以及使用 size 屬性取得字典中的項目數。

{{ request.params[ID] }}

{% if request.params.size > 0 %}

The request parameters collection contains some items.

{% endif %}

日期時間

DateTime 物件代表特定日期與時間。

{{ page.modifiedon | date: 'f' }}

Null

Null 代表空值或不存在的值。 任何嘗試傳回 null 值的輸出都不會轉譯任何內容。 它會在條件中被視為 false。

{% if request.params[ID] %}

This will render if the ID request parameter is NOT null.

{% endif %}

請參閱

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

注意

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

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