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

**URL:** <https://discourse.slimframework.com/t/slim-views-how-to-addfilter-for-twig/509>\
**Category:** Questions\
**Created:** [July 15, 2016, 10:19am UTC](https://discourse.slimframework.com/t/slim-views-how-to-addfilter-for-twig/509 "2016-07-15T10:19:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ziriusph](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/ziriusph/32/97_2.png) [@ziriusph](https://discourse.slimframework.com/u/ziriusph)\
**Post date:** [July 15, 2016, 10:19am UTC](https://discourse.slimframework.com/t/slim-views-how-to-addfilter-for-twig/509/1 "2016-07-15T10:19:08Z")

</div>

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);
});
$twig->addFilter($twigJsonDecode);

```

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?

**EDIT**

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