Implement lenientIf option (resolve #265; default off)

See description of the option in liquid-options.ts.
This commit is contained in:
sschuldenzucker
2020-12-06 22:58:08 +08:00
committed by Jun Yang
parent c920ebb282
commit 768fb79e32
5 changed files with 62 additions and 7 deletions
+4
View File
@@ -19,6 +19,8 @@ export interface LiquidOptions {
strictFilters?: boolean;
/** Whether or not to assert variable existence. If set to `false`, undefined variables will be rendered as empty string. Otherwise, undefined variables will cause an exception. Defaults to `false`. */
strictVariables?: boolean;
/** Modifies the behavior of `strictVariables`. If set, a single undefined variable will *not* cause an exception in the context of the `if` tag and the `default` filter. Instead, it will evaluate to `false` and `null`, respectively. Irrelevant if `strictVariables` is not set. Defaults to `false`. **/
lenientIf?: boolean;
/** Strip blank characters (including ` `, `\t`, and `\r`) from the right of tags (`{% %}`) until `\n` (inclusive). Defaults to `false`. */
trimTagRight?: boolean;
/** Similar to `trimTagRight`, whereas the `\n` is exclusive. Defaults to `false`. See Whitespace Control for details. */
@@ -56,6 +58,7 @@ export interface NormalizedFullOptions extends NormalizedOptions {
dynamicPartials: boolean;
strictFilters: boolean;
strictVariables: boolean;
lenientIf: boolean;
trimTagRight: boolean;
trimTagLeft: boolean;
trimOutputRight: boolean;
@@ -85,6 +88,7 @@ export const defaultOptions: NormalizedFullOptions = {
outputDelimiterRight: '}}',
strictFilters: false,
strictVariables: false,
lenientIf: false,
globals: {}
}