fix: some filters throw on nil input, see #481

This commit is contained in:
Harttle
2022-02-27 02:07:59 +08:00
parent 21b78d9ba0
commit 7dfb620d30
14 changed files with 182 additions and 93 deletions
+14
View File
@@ -207,4 +207,18 @@ describe('Issues', function () {
const html = await engine.render(tpl, { v: undefined })
expect(html).to.equal('')
})
it('#481 filters that should not throw', async () => {
const engine = new Liquid()
const tpl = engine.parse(`
{{ foo | join }}
{{ foo | map: "k" }}
{{ foo | reverse }}
{{ foo | slice: 2 }}
{{ foo | newline_to_br }}
{{ foo | strip_html }}
{{ foo | truncatewords }}
`)
const html = await engine.render(tpl, { foo: undefined })
expect(html.trim()).to.equal('')
})
})