mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
fix: support Context as evalValue parameter, #568
This commit is contained in:
+4
-4
@@ -76,15 +76,15 @@ export class Liquid {
|
|||||||
return this.renderToNodeStream(templates, scope, renderOptions)
|
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 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)
|
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))
|
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))
|
return toValueSync(this._evalValue(str, scope))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ export type TagRenderReturn = Generator<unknown, unknown, unknown> | Promise<unk
|
|||||||
|
|
||||||
export abstract class Tag extends TemplateImpl<TagToken> implements Template {
|
export abstract class Tag extends TemplateImpl<TagToken> implements Template {
|
||||||
public name: string
|
public name: string
|
||||||
protected liquid: Liquid
|
public liquid: Liquid
|
||||||
|
|
||||||
public constructor (token: TagToken, remainTokens: TopLevelToken[], liquid: Liquid) {
|
public constructor (token: TagToken, remainTokens: TopLevelToken[], liquid: Liquid) {
|
||||||
super(token)
|
super(token)
|
||||||
|
|||||||
Reference in New Issue
Block a user