Question: How can I limit the length of the text, e.g., 50, and put three dots in the display?

```
{% if myentity.text|length > 50 %}

{% block td_text %} {{ myentity.text}}{% endblock %}

{%endif%}

```

Answer: 
Update for Twig 2 and Twig 3.

truncate filter is not available, instead of it you may use [u-filter](https://twig.symfony.com/doc/3.x/filters/u.html)

here is an example:

```
{{ 'Lorem ipsum'|u.truncate(8) }}
Lorem ip

{{ 'Lorem ipsum'|u.truncate(8, '...') }}
Lorem...

```

Note: this filter is part of StringExtension that can be required by 

```
twig/string-extra

```
I wrote this simple marco for the same purpose, hope it helps:

```
{%- macro stringMaxLength(str, maxLength) -%}
    {%- if str | length < maxLength -%}
        {{ str }}
    {%- else -%}
        {{ str|slice(0, maxLength) }}...
    {%- endif -%}
{%- endmacro -%}

```

Usage Example #1 (Output: "my long string here ..."):

```
{{ _self.stringMaxLength("my long string here bla bla bla la", 20) }}

```

Usage Example #2 (Output: "shorter string!"):

```
{{ _self.stringMaxLength("shorter string!", 20) }}

```