symfony - Join property values of a list of objects in twig -


is possible join values of properties of list of objects displaying it?
like:

{{ users|join(', ', username) }} 

where users objects, having getusername() method.
suppose join doesn't take additional argument, there workaround achieve similar? can not use __tostring() function, represents else...

you use..

{% set usernames = [] %}  {% user in users %}     {% set usernames = usernames|merge([user.username]) %} {% endfor %}  {{ usernames|join(', ') }} 

not prettiest though.

you make custom twig filter it.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -