refactor: _evalToken renamed to evalToken

BREAKING CHANGE: `evalToken` now returns a generator (LiquidJS async), which is different from `evalToken` in previous LiquidJS versions.
This commit is contained in:
Jun Yang
2022-11-27 14:04:02 +08:00
parent 92992689cd
commit 4e1a30a20c
10 changed files with 26 additions and 27 deletions
+3 -3
View File
@@ -1,4 +1,4 @@
import { _evalToken } from '../render'
import { evalToken } from '../render'
import { Context } from '../context'
import { identify } from '../util/underscore'
import { FilterImplOptions } from './filter-impl-options'
@@ -20,8 +20,8 @@ export class Filter {
public * render (value: any, context: Context): IterableIterator<unknown> {
const argv: any[] = []
for (const arg of this.args as FilterArg[]) {
if (isKeyValuePair(arg)) argv.push([arg[0], yield _evalToken(arg[1], context)])
else argv.push(yield _evalToken(arg, context))
if (isKeyValuePair(arg)) argv.push([arg[0], yield evalToken(arg[1], context)])
else argv.push(yield evalToken(arg, context))
}
return this.impl.apply({ context, liquid: this.liquid }, [value, ...argv])
}
+2 -2
View File
@@ -1,4 +1,4 @@
import { _evalToken } from '../render/expression'
import { evalToken } from '../render/expression'
import { Context } from '../context/context'
import { Tokenizer } from '../parser/tokenizer'
import { Token } from '../tokens/token'
@@ -24,7 +24,7 @@ export class Hash {
* render (ctx: Context): Generator<unknown, Record<string, any>, unknown> {
const hash = {}
for (const key of Object.keys(this.hash)) {
hash[key] = this.hash[key] === undefined ? true : yield _evalToken(this.hash[key], ctx)
hash[key] = this.hash[key] === undefined ? true : yield evalToken(this.hash[key], ctx)
}
return hash
}