perf: improve performance by 4x by simplified parseFile

- previously deprecated `getTemplate()` and `getTemplateSync()` not no longer supported
- `opts` no longer support dynamic set in `parseFile()`, `renderFile()` arguments
This commit is contained in:
harttle
2021-09-27 23:04:41 +08:00
parent 6b9f872bcc
commit 24f5346084
14 changed files with 103 additions and 151 deletions
+4 -3
View File
@@ -4,8 +4,8 @@ import { expect } from 'chai'
export const liquid = new Liquid()
export function render (src: string, ctx?: object, opts?: LiquidOptions) {
return liquid.parseAndRender(src, ctx, opts)
export function render (src: string, ctx?: object) {
return liquid.parseAndRender(src, ctx)
}
export async function test (src: string, ctx: object | string, dst?: string, opts?: LiquidOptions) {
@@ -13,5 +13,6 @@ export async function test (src: string, ctx: object | string, dst?: string, opt
dst = ctx as string
ctx = {}
}
return expect(await render(src, ctx as object, opts)).to.equal(dst)
const engine = opts ? new Liquid(opts) : liquid
return expect(await engine.parseAndRender(src, ctx as object)).to.equal(dst)
}