ivovalchev/twig-truncate-html

A Twig truncate_html filter without breaking HTML tags.

1.0.0 2020-05-05 08:19 UTC

This package is auto-updated.

Last update: 2021-10-05 12:42:12 UTC


README

composer require ivovalchev/twig-truncate-html

And add it to your services.yaml:

    app.twig_extension:
        class: IvoValchev\TruncateHtmlExtension\TruncateHtmlExtension
        tags:
            - { name: twig.extension }

How to use

{{ "<p>hello world</p>"|truncate_html(5) }}