[Slim\Views] how to addFilter() for twig?

Hello! I don’t know if this forum also allows Slim Views Twig support but I;ll just give it a shot.

I am trying to enable json_decode() function for twig with this setup:

$app = new Slim([
    'view' => new Twig(),
    'templates.path' => INC_ROOT .'/app/views'

$view = $app->view();
$view->parserExtensions = [
    new TwigExtension,
    new Twig_Extension_Debug(),

then implementing using the addFilter() method:

$twig = $app->view()->getEnvironment();
$twigJsonDecode = new Twig_SimpleFilter("json_decode", function ($json) {
    return json_decode($json, true);

but it seems like Twig Views does not recogize the filter?

The function "json_decode" does not exist in "/topic.html" at line 100

How can I enable it?


Figured it out. Apparently, i should be using addFunction() instead.