feat: support not operator, #575

This commit is contained in:
Harttle
2023-01-03 01:34:03 +08:00
committed by Harttle
parent aafaa0b4f9
commit 3f21382d43
7 changed files with 74 additions and 33 deletions
+12
View File
@@ -377,4 +377,16 @@ describe('Issues', function () {
const html = await liquid.parseAndRender(tpl)
expect(html).to.match(/\w+, January \d+, 2023 at \d+:\d\d [ap]m [-+]\d\d\d\d/)
})
it('#575 Add support for Not operator', async () => {
const liquid = new Liquid()
const tpl = `
{% if link and not button %}
<a href="{{ link }}">Lot more code here</a>
{% else %}
<div>Lot more code here</div>
{% endif %}`
const ctx = { link: 'https://example.com', button: false }
const html = await liquid.parseAndRender(tpl, ctx)
expect(html.trim()).to.equal('<a href="https://example.com">Lot more code here</a>')
})
})