I'm trying to display all elements inside an array and separate them with a line break, but I can't get it work.
Here is what I tried:
{{ user.roles | join('<br/>') }}
{{ user.roles | join('<br/>' | raw) }}
{{ user.roles | join('\n' | nl2br | raw) }}
Everytime I get something like:
ROLE_PARENT<br/>ROLE_ADMIN<br/>ROLE_MANAGER<br/>ROLE_USER
How can I tell twig to render <br/>
as html ?
I could loop through the array but it's not the first time I tried to render html tag and I would like a definitive solution to this problem.
| raw
necessary? Isn't'\n' | raw
evaluated first and thenjoin()
on the result of it? – Stefanysteffane