/TwigTruncateBundle

A symfony2 bundle to include the TwigTruncateExtension into your app.

Primary LanguagePHPMIT LicenseMIT

TwigTruncateBundle

A Symfony bundle to include the TwigTruncateExtension into your app. The TwigTruncateExtension allows you to truncate text while preserving HTML tags.

Installation

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],
]

Usage

See the TwigTruncateExtension's documentation.