mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-19 06:20:38 -07:00
feat: nil/null/empty/blank literals, resolves #102
This commit is contained in:
@@ -19,22 +19,20 @@ describe('tags/case', function () {
|
||||
const html = await liquid.parseAndRender(src)
|
||||
return expect(html).to.equal('foo')
|
||||
})
|
||||
it('should resolve empty string if not hit', async function () {
|
||||
const src = '{% case empty %}' +
|
||||
'{% when "foo" %}foo{% when ""%}bar' +
|
||||
'{%endcase%}'
|
||||
const ctx = {
|
||||
empty: ''
|
||||
}
|
||||
const html = await liquid.parseAndRender(src, ctx)
|
||||
it('should resolve blank as empty string', async function () {
|
||||
const src = '{% case blank %}{% when ""%}bar{%endcase%}'
|
||||
const html = await liquid.parseAndRender(src)
|
||||
return expect(html).to.equal('bar')
|
||||
})
|
||||
it('should resolve empty as empty string', async function () {
|
||||
const src = '{% case empty %}{% when ""%}bar{%endcase%}'
|
||||
const html = await liquid.parseAndRender(src)
|
||||
return expect(html).to.equal('bar')
|
||||
})
|
||||
it('should accept empty string as branch name', async function () {
|
||||
const src = '{% case false %}' +
|
||||
'{% when "foo" %}foo{% when ""%}bar' +
|
||||
'{%endcase%}'
|
||||
const src = '{% case "" %}{% when ""%}bar{%endcase%}'
|
||||
const html = await liquid.parseAndRender(src)
|
||||
return expect(html).to.equal('')
|
||||
return expect(html).to.equal('bar')
|
||||
})
|
||||
it('should support boolean case', async function () {
|
||||
const src = '{% case false %}' +
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import Liquid from 'src/liquid'
|
||||
import { expect, use } from 'chai'
|
||||
import * as chaiAsPromised from 'chai-as-promised'
|
||||
import IContext from 'src/scope/icontext'
|
||||
import { Context } from 'src/scope/scope'
|
||||
|
||||
use(chaiAsPromised)
|
||||
|
||||
describe('tags/for', function () {
|
||||
let liquid: Liquid, ctx: IContext
|
||||
let liquid: Liquid, ctx: Context
|
||||
before(function () {
|
||||
liquid = new Liquid()
|
||||
liquid.registerTag('throwingTag', {
|
||||
|
||||
Reference in New Issue
Block a user