I'm using Symfony 2.3 and have deprecation warnings in my profiler related to Twig. Such as:
DEPRECATION - Using "replace" with character by character replacement is deprecated
and will be removed in Twig 2.0
And the |replace
tag seems to be still part of the Twig documentation, so I am a little confused on how to deal with this Warning.
Also, I get similar Deprecation Warnings from third-party bundles that I use.
You need to change the way you pass the arguments to replace function in twig :
{{str | replace ('a','b') }}
{{str | replace ({'a': 'b'}) }}
Before it was two arguments, now it's an array.
You can check in the code source that it's not the replace twig_replace_filter function wich is deprecated but only one way of calling it : https://github.com/twigphp/Twig/blob/1.x/lib/Twig/Extension/Core.php#L534
Note that the twig doc display the right example : http://twig.sensiolabs.org/doc/filters/replace.html