looping in twig and break after three iteration

后端 未结 1 921
暖寄归人
暖寄归人 2021-01-13 11:16

I have the following twig code:

{% for likeditem in user.getItemLikes() %}
    //iterate over each liked items here
{% endfor %}

however I

相关标签:
1条回答
  • 2021-01-13 12:18

    Looks like you can use the slice filter for what you are trying to do:

    {% for likeditem in user.getItemLikes()|slice(0,3) %}
        //iterate over each liked items here
    {% endfor %}
    
    0 讨论(0)
提交回复
热议问题