Browse the docs

length

Counts the characters in text, the items in a list or the keys in a record.

Details #

length(value) takes exactly one argument and returns a number.

  • Text: the number of characters. length("héllo") is 5.

  • List: the number of items.

  • Record: the number of keys.

  • Nothing (null): 0.

  • Anything else is turned into text first, so length(1234) is 4.

value.length gives the same count for text and lists.

Parameters #

Takes 1 argument. {{ length(text) }}

Examples #

length("héllo")
→ 5
length(items)
→ 3
Sample variableValue
items["a", "b", "c"]
items.length > 2 ? "many" : "few"
→ many
Sample variableValue
items["a", "b", "c"]

Gotchas #

  • .length on a record is not the key count; it reads a field called length. Use length(record).