Fix: respect parameter order when using "for ... reversed" (#231)

* fix: spelling

* fix: respect param order for reversed

* docs: add for-reversed order details

* perf: improve performance by 4x by simplified parseFile

BREAKING CHANGES:
- previously deprecated `getTemplate()` and `getTemplateSync()` not no longer supported
- `opts` no longer support dynamic set in `parseFile()`, `renderFile()` arguments

* perf: parse filenames in parse() insteadof render()

* docs: update description of LiquidJS

Co-authored-by: harttle <[email protected]>
This commit is contained in:
Steve Stedman
2021-09-30 22:15:09 +08:00
committed by Jun Yang
co-authored by harttle
parent 9012133e07
commit fb787e8847
3 changed files with 39 additions and 9 deletions
+6 -5
View File
@@ -207,25 +207,26 @@ describe('tags/for', function () {
})
})
describe('reverse', function () {
describe('reversed', function () {
it('should support for reversed in the last position', async function () {
const src = '{% for i in (1..5) limit:2 reversed %}{{ i }}{% endfor %}'
const src = '{% for i in (1..8) limit:2 reversed %}{{ i }}{% endfor %}'
const html = await liquid.parseAndRender(src, scope)
return expect(html).to.equal('21')
})
it('should support for reversed in the first position', async function () {
const src = '{% for i in (1..5) reversed limit:2 %}{{ i }}{% endfor %}'
const src = '{% for i in (1..8) reversed limit:2 %}{{ i }}{% endfor %}'
const html = await liquid.parseAndRender(src, scope)
return expect(html).to.equal('21')
return expect(html).to.equal('87')
})
it('should support for reversed in the middle position', async function () {
const src = '{% for i in (1..5) offset:2 reversed limit:4 %}{{ i }}{% endfor %}'
const src = '{% for i in (1..8) offset:2 reversed limit:3 %}{{ i }}{% endfor %}'
const html = await liquid.parseAndRender(src)
return expect(html).to.equal('543')
})
})
describe('sync', function () {
it('should support sync', function () {
const src = '{% for i in (1..5) %}{{i}}{%endfor%}'