Awee

length

Length returns the number of characters in a string, bytes in a byte slice, or elements in a slice/array/map.

Length returns the number of characters in a string, bytes in a byte slice, or elements in a slice/array/map.

Input

string bytes array map

Parameters

None

Returns

int

Examples

Count characters in a name

Input

name = "Alice"

Template

{{ name | length }}

Output

5

Count items in a cart

Input

items = ["mug", "pen", "pad"]

Template

{{ items | length }}

Output

3

How is this guide?

On this page