fix: elsif is not supported for unless, fixes #268

This commit is contained in:
harttle
2020-12-08 00:16:36 +08:00
parent a492d8e23d
commit 2bbf50171b
5 changed files with 47 additions and 8 deletions
+5 -1
View File
@@ -1,5 +1,9 @@
import { Liquid } from '../../../../src/liquid'
import { expect } from 'chai'
import * as chai from 'chai'
import * as chaiAsPromised from 'chai-as-promised'
const expect = chai.expect
chai.use(chaiAsPromised)
describe('tags/if', function () {
const liquid = new Liquid()
+5
View File
@@ -14,6 +14,11 @@ describe('tags/unless', function () {
const html = await liquid.parseAndRender(src)
return expect(html).to.equal('no')
})
it('should support elsif', async function () {
const src = '{% unless true %}1{%elsif true%}2{%else%}3{%endunless%}'
const html = await liquid.parseAndRender(src)
return expect(html).to.equal('2')
})
it('should render unless when predicate yields false', async function () {
const src = '{% unless false %}yes{%else%}no{%endunless%}'
const html = await liquid.parseAndRender(src)