Filter collection method in Twig

Hi Folks,

Is it possible to use filter() collection method in Twig? If yes, how should it look?
I do not know how to define function closure for Twig.

Thanks for your help,

Hi @vimre

Closures don’t work in Twig, so you have to filter by creating a new collection in a {% for %} loop.

{% set array = collect() %}
{% for item in items %}
    {% do array.push({ title: item.title, ... }) %}
{% endfor %}

I understand. Thanks for your feedback, Samuel.