Truncate text in Twig & Symfony 2

In the core symfony / twig do not have a simple truncate-text-function, like substr() in PHP. Therefor you have to activate the Twig-Text-Extension:

Now you can easily truncate as you like:

If you want to preserve whole words, you have to set the 2nd parameter:

With the 3rd parameter you can override the default seperator ‘…':

 

Thanks Scott :)