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:
@@ -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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user