A Symfony bundle to include the TwigTruncateExtension into your app. The TwigTruncateExtension allows you to truncate text while preserving HTML tags.
Add the bundle to your app's composer.json
:
"require": {
"dzango/twig-truncate-bundle": "^1.0",
...
}
Enable the bundle in your app's Appkernel
(Only for symfony projects below 4):
# app/AppKernel.php
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
...
new Dzango\Bundle\TwigTruncateBundle\TwigTruncateBundle(),
...
);
Note:
For symfony 4 and above the bundle will automatically enabled in your app. In case the bundle does not enabled, add it to bundle list.
#config/bundles.php
return [
...
Dzango\Bundle\TwigTruncateBundle\TwigTruncateBundle::class => ['all' => true],
]
See the TwigTruncateExtension's documentation.