mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 22:10:41 -07:00
fix: in conditionals, don't render anything after an else branch (#671)
* fix: only render the first 'else' template in the case of multiples * fix: empty else block and cases with when conditions * fix: don't render elsif after else * chore: Update src/tags/unless.ts * chore: Update src/tags/if.ts * chore: Update src/tags/case.ts --------- Co-authored-by: Jun Yang <[email protected]>
This commit is contained in:
co-authored by
Jun Yang
parent
1937aa1f1d
commit
f816955704
@@ -469,4 +469,20 @@ describe('Issues', function () {
|
||||
const result = engine.parseAndRenderSync('{{ÜLKE}}', { ÜLKE: 'Türkiye' })
|
||||
expect(result).toEqual('Türkiye')
|
||||
})
|
||||
it('#670 Should not render anything after an else branch', () => {
|
||||
const engine = new Liquid()
|
||||
const result = engine.parseAndRenderSync('{% assign value = "this" %}' +
|
||||
'{% if false %}don\'t show' +
|
||||
'{% else %}show {{ value }}' +
|
||||
'{% else %}don\'t show{% endif %}', {})
|
||||
expect(result).toEqual('show this')
|
||||
})
|
||||
it('#672 Should not render an elseif after an else branch', () => {
|
||||
const engine = new Liquid()
|
||||
const result = engine.parseAndRenderSync('{% if false %}don\'t show' +
|
||||
'{% else %}show' +
|
||||
'{% elsif true %}don\'t show' +
|
||||
'{% endif %}', {})
|
||||
expect(result).toEqual('show')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user