fix: support Context as evalValue parameter, #568

This commit is contained in:
Harttle
2022-12-12 19:41:29 +08:00
committed by Harttle
parent f4a033ecea
commit 0f4916bc5a
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -76,15 +76,15 @@ export class Liquid {
return this.renderToNodeStream(templates, scope, renderOptions)
}
public _evalValue (str: string, scope?: object): IterableIterator<any> {
public _evalValue (str: string, scope?: object | Context): IterableIterator<any> {
const value = new Value(str, this)
const ctx = new Context(scope, this.options)
const ctx = scope instanceof Context ? scope : new Context(scope, this.options)
return value.value(ctx, false)
}
public async evalValue (str: string, scope?: object): Promise<any> {
public async evalValue (str: string, scope?: object | Context): Promise<any> {
return toPromise(this._evalValue(str, scope))
}
public evalValueSync (str: string, scope?: object): any {
public evalValueSync (str: string, scope?: object | Context): any {
return toValueSync(this._evalValue(str, scope))
}
+1 -1
View File
@@ -9,7 +9,7 @@ export type TagRenderReturn = Generator<unknown, unknown, unknown> | Promise<unk
export abstract class Tag extends TemplateImpl<TagToken> implements Template {
public name: string
protected liquid: Liquid
public liquid: Liquid
public constructor (token: TagToken, remainTokens: TopLevelToken[], liquid: Liquid) {
super(token)