diff --git a/flextype/twig/JsonTwigExtension.php b/flextype/twig/JsonTwigExtension.php index 0eee281f..e934d19d 100644 --- a/flextype/twig/JsonTwigExtension.php +++ b/flextype/twig/JsonTwigExtension.php @@ -11,6 +11,7 @@ namespace Flextype; use Twig_Extension; use Twig_SimpleFunction; +use Twig_SimpleFilter; class JsonTwigExtension extends Twig_Extension { @@ -40,6 +41,19 @@ class JsonTwigExtension extends Twig_Extension ]; } + /** + * Returns a list of filters to add to the existing list. + * + * @return array + */ + public function getFilters() : array + { + return [ + new Twig_SimpleFilter('json_decode', [$this, 'decode']), + new Twig_SimpleFilter('json_encode', [$this, 'encode']), + ]; + } + /** * Encode JSON */