Truncate Filter - limit number of characters

For limiting number of characters of any text you can use the "truncate" filter in twig. 

The usage examples exists at the code examples. 

On how to enable twig enable code examples please read in this article: Enabling twig code examples

{# use the truncate filter for lower the text length. arguments are: (numchars, preserve words(true|false), separator="...")#}

{{ some_attribute|truncate }}
{{ some_attribute|truncate(50) }}
{{ some_attribute|truncate(100, true) }}
{{ some_attribute|truncate(150, true, "...") }}
The second parameter: Number of characters. Default is 100
The third parameter - if preserve full word (true/false) . default is false. 
and the fourth parameter -  string that will be added if the text was truncated. by default is "..."
For example to use it in post list item you can write: 
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.