In paragraph template I'm writing out paragraph field value like this:
{{ content.field_text['0']['#context'].value }}
and that works well. Now I want to support tokens while printing that text. I.e. if inside text I find "%current%" string I want to replace it with path to current page.
I'm also able to get path to current page like this:
{{ url('<current>') }}
And I can do search replace with static text like this:
{{ content.field_text['0']['#context'].value|replace({'%url%': "Dummy text"}) }}
and this also works.
But when I try to put it all together like this:
{{ content.field_text['0']['#context'].value|replace({'%url%': url('<current>') }) }}
it's not working. In that case I get error message:
Notice: Array to string conversion in twig_replace_filter() (line 486 of vendor/twig/twig/lib/Twig/Extension/Core.php).
And instead of real current page path token is replaced with "Array" string.
Also tried to get this to variable first and then put variable as second parameter for replace function, but that didn't work neither.
Any advice how to achieve this?
content.field_text['0']['#context'].valuealways is a string? - xabbuh