mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
chore: update liquid options to match raw filters
This commit is contained in:
+7
-10
@@ -3,7 +3,8 @@ import { LRU, LiquidCache } from './cache'
|
||||
import { FS } from './fs/fs'
|
||||
import * as fs from './fs/node'
|
||||
import { defaultOperators, Operators } from './render'
|
||||
import { filters } from './filters'
|
||||
import { json } from './filters/misc'
|
||||
import { escape } from './filters/html'
|
||||
|
||||
type OutputEscape = (value: any) => string
|
||||
type OutputEscapeOption = 'escape' | 'json' | OutputEscape
|
||||
@@ -182,15 +183,11 @@ export function normalize (options: LiquidOptions): NormalizedFullOptions {
|
||||
return options as NormalizedFullOptions
|
||||
}
|
||||
|
||||
function getOutputEscapeFunction (nameOrFunction: OutputEscapeOption) {
|
||||
if (isString(nameOrFunction)) {
|
||||
const filterImpl = filters[nameOrFunction]
|
||||
assert(isFunction(filterImpl), `filter "${nameOrFunction}" not found`)
|
||||
return filterImpl
|
||||
} else {
|
||||
assert(isFunction(nameOrFunction), '`outputEscape` need to be of type string or function')
|
||||
return nameOrFunction
|
||||
}
|
||||
function getOutputEscapeFunction (nameOrFunction: OutputEscapeOption): OutputEscape {
|
||||
if (nameOrFunction === 'escape') return escape
|
||||
if (nameOrFunction === 'json') return json
|
||||
assert(isFunction(nameOrFunction), '`outputEscape` need to be of type string or function')
|
||||
return nameOrFunction
|
||||
}
|
||||
|
||||
export function normalizeDirectoryList (value: any): string[] {
|
||||
|
||||
Reference in New Issue
Block a user