Skip to content

Commit

Permalink
fix: support Context as evalValue parameter, #568
Browse files Browse the repository at this point in the history
  • Loading branch information
harttle committed Dec 12, 2022
1 parent f4a033e commit 0f4916b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/liquid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
2 changes: 1 addition & 1 deletion src/template/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0f4916b

Please sign in to comment.