This filter allows you to call dynamic filters in twig.
{{ set filters = 'upper|nl2br' }}
{{ value|apply_filter(filters) }}
{{ value|apply_filter("default('abc')|json_encode") }}
A filter for e.g. a News system, where the title filter is stored in the database:
{% for item in newsItems %}
<h2>{{ item.title|apply_filter(databaseSettings.newsFilter) }}</h2>
{% endfor %}
composer.phar require marcj/twig-apply_filter-bundle
Open your AppKernel.php
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new MJS\TwigApplyFilter\MJSTwigApplyFilterBundle(),
);
}