mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 12:20:40 -07:00
fix: case should render multiple when statements
This commit is contained in:
@@ -329,4 +329,21 @@ describe('Issues', function () {
|
||||
expect(await liquid.parseAndRender('{{i.i}}', context)).to.equal('1')
|
||||
expect(await liquid.parseAndRender('{{j.j}}', context)).to.equal('1')
|
||||
})
|
||||
it('#559 Case/When should evaluate multiple When statements', async () => {
|
||||
const liquid = new Liquid()
|
||||
const tpl = `
|
||||
{% assign tag = 'Love' %}
|
||||
|
||||
{% case tag %}
|
||||
{% when 'Love' or 'Luck' %}
|
||||
This is a love or luck potion.
|
||||
{% when 'Strength','Health', 'Love' %}
|
||||
This is a strength or health or love potion.
|
||||
{% else %}
|
||||
This is a potion.
|
||||
{% endcase %}
|
||||
`
|
||||
const html = await liquid.parseAndRender(tpl)
|
||||
expect(html).to.match(/^\s*This is a love or luck potion.\s+This is a strength or health or love potion.\s*$/)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -71,4 +71,12 @@ describe('tags/case', function () {
|
||||
const html = await liquid.parseAndRender(src)
|
||||
return expect(html).to.equal('foo')
|
||||
})
|
||||
it('should render multiple matching branches', async function () {
|
||||
const src = '{% case "b" %}' +
|
||||
'{% when "a", "b" %}first' +
|
||||
'{% when "b" %}second' +
|
||||
'{%endcase%}'
|
||||
const html = await liquid.parseAndRender(src)
|
||||
return expect(html).to.equal('firstsecond')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user