size

返回字串中的字元數或陣列中的項目數。

輸入

{{ "Ground control to Major Tom." | size }}

輸出

28

輸入

{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}

{{ my_array.size }}

輸出



4

當您需要在標籤內使用篩選器時,可以使用帶有點表示法的 size

{% if site.pages.size > 10 %}
  This is a big website!
{% endif %}