shorten

Shortens a string to a given number of characters and appends an optional ellipsis, without cutting off words. To avoid open or incomplete HTML tags, all tags will be removed before shortening a string.

@{ variable | shorten (maxChars, ellipsis) }

It is also possible to just use an integer as a shorthand version:

@{ variable | 100 }

Parameters

maxChars
The maximum characters of the truncated string.
ellipsis ...
A string appended to the returned variable value, in case the value was truncated.

Example

This example demonstrates how the shorten filter creates a brief preview of page content, useful for displaying summaries in blog post listings.

@{ +main | findFirstParagraph | 150 }
sanitize stripEnd