mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
fix: elsif is not supported for unless, fixes #268
This commit is contained in:
@@ -42,4 +42,16 @@ describe('Issues', function () {
|
||||
const html = engine.parseAndRenderSync(template)
|
||||
expect(html).to.equal('This is a code snippet showing how {% breaks the raw block.')
|
||||
})
|
||||
it('#268 elsif is not supported for unless', () => {
|
||||
const template = `{%- unless condition1 -%}
|
||||
<div>X</div>
|
||||
{%- elsif condition2 -%}
|
||||
<div>Y</div>
|
||||
{%- else %}
|
||||
<div>Z</div>
|
||||
{% endunless %}`
|
||||
const engine = new Liquid()
|
||||
const html = engine.parseAndRenderSync(template, { condition1: true, condition2: true })
|
||||
expect(html).to.equal('<div>Y</div>')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { Liquid } from '../../../../src/liquid'
|
||||
import { expect } from 'chai'
|
||||
import * as chai from 'chai'
|
||||
import * as chaiAsPromised from 'chai-as-promised'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(chaiAsPromised)
|
||||
|
||||
describe('tags/if', function () {
|
||||
const liquid = new Liquid()
|
||||
|
||||
@@ -14,6 +14,11 @@ describe('tags/unless', function () {
|
||||
const html = await liquid.parseAndRender(src)
|
||||
return expect(html).to.equal('no')
|
||||
})
|
||||
it('should support elsif', async function () {
|
||||
const src = '{% unless true %}1{%elsif true%}2{%else%}3{%endunless%}'
|
||||
const html = await liquid.parseAndRender(src)
|
||||
return expect(html).to.equal('2')
|
||||
})
|
||||
it('should render unless when predicate yields false', async function () {
|
||||
const src = '{% unless false %}yes{%else%}no{%endunless%}'
|
||||
const html = await liquid.parseAndRender(src)
|
||||
|
||||
Reference in New Issue
Block a user