len

将以下英文翻译为中文:

len

https://gohugo.io/functions/len/

Returns the length of a string, slice, map, or collection.

语法

len INPUT

With a string:

1
2
{{ "ab" | len }} → 2
{{ "" | len }} → 0

With a slice:

1
2
{{ slice "a" "b" | len }} → 2
{{ slice | len }} → 0

With a map:

1
2
{{ dict "a" 1 "b" 2  | len }} → 2
{{ dict | len }} → 0

With a collection:

1
{{ site.RegularPages | len }} → 42

You may also determine the number of pages in a collection with:

1
{{ site.RegularPages.Len }} → 42

另请参阅