Automatic Text Excerpt / Truncated Texts with Twig
Today I had to create a grid of cards for a search page. To ensure a consistent layout I wanted the excerpt texts to be cut off, if necessary, at certain length.
This can be done easily when using the truncate filter in the Twig template engine for PHP:
14 stands for the number of words after which the text will be cut off and an ellipsis is added.