feat: Access array item by negative index, closes #486

This commit is contained in:
Harttle
2022-03-06 00:52:22 +08:00
parent c503cb23df
commit 049685b9a0
4 changed files with 25 additions and 13 deletions
+5
View File
@@ -227,4 +227,9 @@ describe('Issues', function () {
const html = await engine.parseAndRender(`{{ foo | concat | json }}`)
expect(html).to.equal('[]')
})
it('#486 Access array items from the right with negative indexes', async () => {
const engine = new Liquid()
const html = await engine.parseAndRender(`{% assign a = "x,y,z" | split: ',' -%}{{ a[-1] }} {{ a[-3] }} {{ a[-8] }}`)
expect(html).to.equal('z x ')
})
})