Jul 16, 2019 in Drupal 8, Snippets

Sometimes you need a body text that is trimmed. No need to install contrib modules. Here's a little snippet:

{% set text = content.body|render|striptags %}
{{ text|length > 200 ? text|slice(0, 200)|raw ~ '...' : text|raw }}