Skip to content

Instantly share code, notes, and snippets.

View tuarrep's full-sized avatar
😷
Stay at home!

Nicolas Perraut tuarrep

😷
Stay at home!
View GitHub Profile
@tuarrep
tuarrep / TruncateHtmlExtension.php
Last active June 29, 2016 14:52 — forked from leon/TruncateHtmlExtension.php
Symfony 2 Twig Extension that truncates html and preserves tags stop at the end of the word
<?php
/**
* Truncate Html string without stripping tags
* register in Resources/config/services.yml with:
* services:
* truncatehtml.twig.extension:
* class: Radley\TwigExtensionBundle\Extension\TruncateHtmlExtension
* tags:
* - { name: twig.extension }
*