mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 22:10:41 -07:00
feat: exported Drop interface for #107
Deprecate snake_cased options and APIs, sed #109
This commit is contained in:
+47
-41
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
import { deprecate } from './util/deprecate'
|
||||
import * as _ from './util/underscore'
|
||||
|
||||
export interface LiquidOptions {
|
||||
@@ -11,25 +10,25 @@ export interface LiquidOptions {
|
||||
cache?: boolean
|
||||
/** `dynamicPartials`: if set, treat `<filepath>` parameter in `{%include filepath %}`, `{%layout filepath%}` as a variable, otherwise as a literal value. Defaults to `true`. */
|
||||
dynamicPartials?: boolean
|
||||
/** `strict_filters` is used to enable strict filter existence. If set to `false`, undefined filters will be rendered as empty string. Otherwise, undefined filters will cause an exception. Defaults to `false`. */
|
||||
strict_filters?: boolean
|
||||
/** `strict_variables` is used to enable strict variable derivation. If set to `false`, undefined variables will be rendered as empty string. Otherwise, undefined variables will cause an exception. Defaults to `false`. */
|
||||
strict_variables?: boolean
|
||||
/** `trim_tag_right` is used to strip blank characters (including ` `, `\t`, and `\r`) from the right of tags (`{% %}`) until `\n` (inclusive). Defaults to `false`. */
|
||||
trim_tag_right?: boolean
|
||||
/** `trim_tag_left` is similar to `trim_tag_right`, whereas the `\n` is exclusive. Defaults to `false`. See Whitespace Control for details. */
|
||||
trim_tag_left?: boolean
|
||||
/** ``trim_output_right` is used to strip blank characters (including ` `, `\t`, and `\r`) from the right of values (`{{ }}`) until `\n` (inclusive). Defaults to `false`. */
|
||||
trim_output_right?: boolean
|
||||
/** `trim_output_left` is similar to `trim_output_right`, whereas the `\n` is exclusive. Defaults to `false`. See Whitespace Control for details. */
|
||||
trim_output_left?: boolean
|
||||
/** `tag_delimiter_left` and `tag_delimiter_right` are used to override the delimiter for liquid tags **/
|
||||
tag_delimiter_left?: string,
|
||||
tag_delimiter_right?: string,
|
||||
/** `output_delimiter_left` and `output_delimiter_right` are used to override the delimiter for liquid outputs **/
|
||||
output_delimiter_left?: string,
|
||||
output_delimiter_right?: string,
|
||||
/** `greedy` is used to specify whether `trim_left`/`trim_right` is greedy. When set to `true`, all consecutive blank characters including `\n` will be trimed regardless of line breaks. Defaults to `true`. */
|
||||
/** `strictFilters` is used to enable strict filter existence. If set to `false`, undefined filters will be rendered as empty string. Otherwise, undefined filters will cause an exception. Defaults to `false`. */
|
||||
strictFilters?: boolean
|
||||
/** `strictVariables` is used to enable strict variable derivation. If set to `false`, undefined variables will be rendered as empty string. Otherwise, undefined variables will cause an exception. Defaults to `false`. */
|
||||
strictVariables?: boolean
|
||||
/** `trimTagRight` is used to strip blank characters (including ` `, `\t`, and `\r`) from the right of tags (`{% %}`) until `\n` (inclusive). Defaults to `false`. */
|
||||
trimTagRight?: boolean
|
||||
/** `trimTagLeft` is similar to `trimTagRight`, whereas the `\n` is exclusive. Defaults to `false`. See Whitespace Control for details. */
|
||||
trimTagLeft?: boolean
|
||||
/** ``trimOutputRight` is used to strip blank characters (including ` `, `\t`, and `\r`) from the right of values (`{{ }}`) until `\n` (inclusive). Defaults to `false`. */
|
||||
trimOutputRight?: boolean
|
||||
/** `trimOutputLeft` is similar to `trimOutputRight`, whereas the `\n` is exclusive. Defaults to `false`. See Whitespace Control for details. */
|
||||
trimOutputLeft?: boolean
|
||||
/** `tagDelimiterLeft` and `tagDelimiterRight` are used to override the delimiter for liquid tags **/
|
||||
tagDelimiterLeft?: string,
|
||||
tagDelimiterRight?: string,
|
||||
/** `outputDelimiterLeft` and `outputDelimiterRight` are used to override the delimiter for liquid outputs **/
|
||||
outputDelimiterLeft?: string,
|
||||
outputDelimiterRight?: string,
|
||||
/** `greedy` is used to specify whether `trim*Left`/`trim*Right` is greedy. When set to `true`, all consecutive blank characters including `\n` will be trimed regardless of line breaks. Defaults to `true`. */
|
||||
greedy?: boolean
|
||||
}
|
||||
|
||||
@@ -42,16 +41,16 @@ export interface NormalizedFullOptions extends NormalizedOptions {
|
||||
extname: string
|
||||
cache: boolean
|
||||
dynamicPartials: boolean
|
||||
strict_filters: boolean
|
||||
strict_variables: boolean
|
||||
trim_tag_right: boolean
|
||||
trim_tag_left: boolean
|
||||
trim_output_right: boolean
|
||||
trim_output_left: boolean
|
||||
tag_delimiter_left: string,
|
||||
tag_delimiter_right: string,
|
||||
output_delimiter_left: string,
|
||||
output_delimiter_right: string,
|
||||
strictFilters: boolean
|
||||
strictVariables: boolean
|
||||
trimTagRight: boolean
|
||||
trimTagLeft: boolean
|
||||
trimOutputRight: boolean
|
||||
trimOutputLeft: boolean
|
||||
tagDelimiterLeft: string,
|
||||
tagDelimiterRight: string,
|
||||
outputDelimiterLeft: string,
|
||||
outputDelimiterRight: string,
|
||||
greedy: boolean
|
||||
}
|
||||
|
||||
@@ -60,17 +59,17 @@ const defaultOptions: NormalizedFullOptions = {
|
||||
cache: false,
|
||||
extname: '',
|
||||
dynamicPartials: true,
|
||||
trim_tag_right: false,
|
||||
trim_tag_left: false,
|
||||
trim_output_right: false,
|
||||
trim_output_left: false,
|
||||
trimTagRight: false,
|
||||
trimTagLeft: false,
|
||||
trimOutputRight: false,
|
||||
trimOutputLeft: false,
|
||||
greedy: true,
|
||||
tag_delimiter_left: '{%',
|
||||
tag_delimiter_right: '%}',
|
||||
output_delimiter_left: '{{',
|
||||
output_delimiter_right: '}}',
|
||||
strict_filters: false,
|
||||
strict_variables: false
|
||||
tagDelimiterLeft: '{%',
|
||||
tagDelimiterRight: '%}',
|
||||
outputDelimiterLeft: '{{',
|
||||
outputDelimiterRight: '}}',
|
||||
strictFilters: false,
|
||||
strictVariables: false
|
||||
}
|
||||
|
||||
export function normalize (options?: LiquidOptions): NormalizedOptions {
|
||||
@@ -78,6 +77,13 @@ export function normalize (options?: LiquidOptions): NormalizedOptions {
|
||||
if (options.hasOwnProperty('root')) {
|
||||
options.root = normalizeStringArray(options.root)
|
||||
}
|
||||
for (const key of Object.keys(options)) {
|
||||
if (key.indexOf('_') > -1) {
|
||||
const newKey = key.replace(/_([a-z])/g, (_, ch) => ch.toUpperCase())
|
||||
deprecate(`${key} is deprecated, use ${newKey} instead.`, 109)
|
||||
options[newKey] = options[key]
|
||||
}
|
||||
}
|
||||
return options as NormalizedOptions
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user