Twig icon indicating copy to clipboard operation
Twig copied to clipboard

json_encode does not work in last version of Twig

Open tcapb opened this issue 15 years ago • 3 comments

{{'test'|json_encode}} - this construction works as expected.

{% filter json_encode %} test {% endfilter %}

but this construction returns just {}.

tcapb avatar Jan 14 '11 14:01 tcapb

I've added a fix in my fork, markstory@affc21f4d63d2d9e6e6a. The issue seemed to be caused by the filter block using a Twig_Markup instance as the output. json_encode converted this into {}.

markstory avatar Jan 28 '11 03:01 markstory

fixed

fabpot avatar Feb 05 '11 23:02 fabpot

Is it really fixed? I don't see code from @markstory here https://github.com/fabpot/Twig/blob/master/lib/Twig/Extension/Core.php#L51 . And sometimes we have more complex occurrence, when Twig_Markup is item of array.

Koc avatar May 23 '11 16:05 Koc