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