mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 12:20:40 -07:00
fix: lenientIf not working for the umd bundle, closes #313
This commit is contained in:
@@ -12,7 +12,7 @@ import { parseStringLiteral } from '../parser/parse-string-literal'
|
|||||||
import { Context } from '../context/context'
|
import { Context } from '../context/context'
|
||||||
import { range } from '../util/underscore'
|
import { range } from '../util/underscore'
|
||||||
import { Operators } from '../render/operator'
|
import { Operators } from '../render/operator'
|
||||||
import { UndefinedVariableError, InternalUndefinedVariableError } from '../util/error'
|
import { UndefinedVariableError } from '../util/error'
|
||||||
|
|
||||||
export class Expression {
|
export class Expression {
|
||||||
private postfix: Token[]
|
private postfix: Token[]
|
||||||
@@ -52,7 +52,7 @@ function evalPropertyAccessToken (token: PropertyAccessToken, ctx: Context, leni
|
|||||||
try {
|
try {
|
||||||
return ctx.get([variable, ...props])
|
return ctx.get([variable, ...props])
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (lenient && e instanceof InternalUndefinedVariableError) return null
|
if (lenient && e.name === 'InternalUndefinedVariableError') return null
|
||||||
throw (new UndefinedVariableError(e, token))
|
throw (new UndefinedVariableError(e, token))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -44,7 +44,7 @@ export class RenderError extends LiquidError {
|
|||||||
super.update()
|
super.update()
|
||||||
}
|
}
|
||||||
public static is (obj: any): obj is RenderError {
|
public static is (obj: any): obj is RenderError {
|
||||||
return obj instanceof RenderError
|
return obj.name === 'RenderError'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Liquid } from '../..'
|
import { Liquid } from '../..'
|
||||||
|
import { Liquid as LiquidUMD } from '../../dist/liquid.browser.umd.js'
|
||||||
import { expect, use } from 'chai'
|
import { expect, use } from 'chai'
|
||||||
import * as chaiAsPromised from 'chai-as-promised'
|
import * as chaiAsPromised from 'chai-as-promised'
|
||||||
|
|
||||||
@@ -78,4 +79,12 @@ describe('Issues', function () {
|
|||||||
)
|
)
|
||||||
expect(html).to.equal('BAR')
|
expect(html).to.equal('BAR')
|
||||||
})
|
})
|
||||||
|
it('#313 lenientIf not working as expected in umd', async () => {
|
||||||
|
const engine = new LiquidUMD({
|
||||||
|
strictVariables: true,
|
||||||
|
lenientIf: true
|
||||||
|
})
|
||||||
|
const html = await engine.parseAndRender(`{{ name | default: "default name" }}`)
|
||||||
|
expect(html).to.equal('default name')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user