2
我有一個帖子數組,每個帖子都有一個類別。我想從這些類別的子集中顯示3篇文章(我們會說a,b,c)。有核心液體可以做到這一點嗎?除非我只是沒有想到我認爲沒有的東西。循環有條件的液體數組?
例職位的數組:
[
{title: post 1, category: {id: a}},
{title: post 2, category: {id: b}},
{title: post 3, category: {id: c}},
{title: post 4, category: {id: d}},
{title: post 5, category: {id: b}}
]
我需要這樣的僞代碼:
{% for post in posts where category.id == a|b|c limit: 3 %}
或
{% for post in posts %}
{% if post.category.id == a|b|c limit: 3 %}