summaryrefslogtreecommitdiffstats
path: root/docs/content/en/functions/len.md
blob: cdf3cf405556833625e3d050bcc52c06cfd40414 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
title: len
description: Returns the length of a string, slice, map, or collection.
categories: [functions]
menu:
  docs:
    parent: functions
keywords: [length]
signature: ["len INPUT"]
relatedfuncs: []
---

With a string:

```go-html-template
{{ "ab" | len }} → 2
{{ "" | len }} → 0
```

With a slice:

```go-html-template
{{ slice "a" "b" | len }} → 2
{{ slice | len }} → 0
```

With a map:

```go-html-template
{{ dict "a" 1 "b" 2  | len }} → 2
{{ dict | len }} → 0
```

With a collection:

```go-html-template
{{ site.RegularPages | len }} → 42
```

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

```go-html-template
{{ site.RegularPages.Len }} → 42
```