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 including the suffix 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 — handy for keeping long messages from breaking an overlay layout.