Exclude

The exclude filter removes items from an array whose keys match those supplied arguments (space separated) based on a case-insensitive search.

You could use the only filter to achieve the same effect but you should use whichever filter requires you to pass in the least number of arguments.

Including the extension

You will need to include the ArrayExtension in your view bootstrap and pass it to the Twig environment.

use Jadu\Pulsar\Twig\Extension\ArrayExtension;

$twig = new Twig_Environment(...);

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

Example usage

{% 
    set input = {
        'foo': 'fighters',
        'bar': 'enakedladies',
        'baz': 'luhrmann'
    }
%}

{% set output = input|exclude('bar') %}

Ouput:

{
    'foo': 'fighters'
    'baz': 'luhrmann'
}

Pass multiple items as a space separate string, eg: input|exclude('foo bar')

results matching ""

    No results matching ""