Json_Encode with Html String in Twig
I have a problem parsing HTML strings using json_encode. For example my line:
<h5>Name</h5>
In response, my json is destroyed due to ">". I found a solution in PHP:
json_encode('ARRAY', 'JSON_HEX_QUOT | JSON_HEX_TAG')
But I need to do it in TWIG and it doesn't work there. I have a mistake:
An exception has been thrown during the rendering of a template ("Warning: json_encode() expects parameter 2 to be long, string given") in src/Cloud/ApplicationBundle/Resources/views/Filters/tab.html.twig at line 1.
+3
source to share