dreipunktnull/twig-extensions

Useful twig extensions.

v1.0 2018-05-07 09:50 UTC

This package is auto-updated.

Last update: 2022-09-18 18:53:41 UTC


README

A collection of useful, generic twig extensions.

Installation

composer require dreipunktnull/twig-extensions

Configuration

Each extension needs to be added to your Twig_Environment.

HTML2Text

Convert HTML fragments to text with html2text.

$twig->addExtension(new Html2TextExtension());

or, if you use Symfony, tag a new service as twig.extension:

twig.extension.html2text:
    class: DPN\TwigExtensions\Extensions\Html2TextExtension
    tags:
        - { name: twig.extension }

Usage (Twig Filter)

{{ html_fragment | html2text }}

License

MIT