feat: nested property for the where filter, #178

This commit is contained in:
harttle
2019-12-13 01:15:29 +08:00
parent 6502984b50
commit 60ec74f55d
6 changed files with 58 additions and 33 deletions
+17
View File
@@ -169,5 +169,22 @@ Available products:
- Boring sneakers
`)
})
it('should support nested property', async function () {
const authors = [
{ name: 'Alice', books: { year: 2019 } },
{ name: 'Bob', books: { year: 2018 } }
]
const html = await liquid.parseAndRender(
`{% assign recentAuthors = authors | where: 'books.year', 2019 %}
Recent Authors:
{%- for author in recentAuthors %}
- {{author.name}}
{%- endfor %}`,
{ authors }
)
expect(html).to.equal(`
Recent Authors:
- Alice`)
})
})
})