Skip to main content

$(truncate)

$(truncate [length] <'suffix'> [text])

Clamps text to at most length characters. When the text is cut, a suffix (default …) is appended. The result, suffix included, never exceeds length.

An optional custom suffix can be given as a quoted string before the text.

Examples​

$(truncate 20 hello)

Will display "hello" (already short enough)

$(truncate 8 hello wonderful world)

Will display "hello w…"

$(truncate 8 '--' hello wonderful world)

Will display "hello --"

$(truncate 40 {{last_message}})

Will display the last chat message clamped to 40 characters, so long messages don't break an overlay layout.