1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-25 06:00:43 +02:00

feat(core): add json_encode and json_decode twig filter #289

This commit is contained in:
Awilum
2019-11-12 17:36:50 +03:00
parent a1ef3dd245
commit 1cd996cbc7

View File

@@ -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
*/