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
5Count items in a cart
Input
items = ["mug", "pen", "pad"]Template
{{ items | length }}Output
3How is this guide?