feat: jsonify, inspect, to_integer, normalize_whitespace filters

This commit is contained in:
Yang Jun
2024-05-06 21:10:27 +08:00
committed by Jun Yang
parent ea0eab93d1
commit 842b45c96a
19 changed files with 258 additions and 17 deletions
+2 -2
View File
@@ -3,7 +3,7 @@ import { LRU, LiquidCache } from './cache'
import { FS, LookupType } from './fs'
import * as fs from './fs/fs-impl'
import { defaultOperators, Operators } from './render'
import { json } from './filters/misc'
import misc from './filters/misc'
import { escape } from './filters/html'
type OutputEscape = (value: any) => string
@@ -193,7 +193,7 @@ export function normalize (options: LiquidOptions): NormalizedFullOptions {
function getOutputEscapeFunction (nameOrFunction: OutputEscapeOption): OutputEscape {
if (nameOrFunction === 'escape') return escape
if (nameOrFunction === 'json') return json
if (nameOrFunction === 'json') return misc.json
assert(isFunction(nameOrFunction), '`outputEscape` need to be of type string or function')
return nameOrFunction
}