size

巴克励步

发布于:2025-01-02

返回字符串中所包含的字符数或者数组中所包含的条目数量。size 还支持“点标记”(例如 {{ my_string.size }})。这种用法便于你在标签(tag)中使用 size 过滤器,例如条件判断标签(tag)。
输入

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

输出
28
输入

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

{{ my_array | size }}

输出


4
使用“点标记”:

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