How to remove duplicated items in array on Twig?
I have array value in twig such as.
{{ set array = [\"testA
{% set keeper = {} %}
{% set throwaway = [] %}
{% for thing in yourSet.all() %}
{% if thing.id not in throwaway %}
{% set throwaway = throwaway|merge([thing.id]) %}
{% set keeper = keeper|merge([{ slug: thing.slug, title: thing.title}]) %}
{% endif %}
{% endfor %}
Modification on the accepted answer above. I needed to remove duplicates from a set and end up with an object of just slug and title.