implement lenientIf for the unless tag, too

This commit is contained in:
sschuldenzucker
2020-12-06 22:58:08 +08:00
committed by Jun Yang
parent 87d7dd0d37
commit 6f2b24f7ca
4 changed files with 9 additions and 4 deletions
+6 -1
View File
@@ -45,7 +45,12 @@ describe('LiquidOptions#strict*', function () {
const html = await engine.render(tpl, {'defined3': 'bla'}, strictLenientOpts)
return expect(html).to.equal('bla')
})
it('should still throw with an undefined variable in an expression', function () {
it('should not throw in `unless` with a single variable', async function () {
const tpl = engine.parse('before{% unless notdefined %}X{% else %}{{notdefined}}{% endunless %}after')
const html = await engine.render(tpl, ctx, strictLenientOpts)
return expect(html).to.equal('beforeXafter')
})
it('should still throw with an undefined variable in a compound `if` expression', function () {
const tpl = engine.parse('{% if notdefined == 15 %}a{% endif %}')
const fhtml = engine.render(tpl, ctx, strictLenientOpts)
return expect(fhtml).to.be.rejectedWith(/undefined variable: notdefined/)