feat: globals shared between tags, see #185

This commit is contained in:
harttle
2020-02-08 04:59:23 +08:00
parent fc0cf6fe7b
commit 870e7ec6aa
4 changed files with 29 additions and 9 deletions
+6 -2
View File
@@ -34,6 +34,8 @@ export interface LiquidOptions {
greedy?: boolean;
/** `fs` is used to override the default file-system module with a custom implementation. */
fs?: IFS;
/** the global environment passed down to all partial templates, i.e. templates included by `include`, `layout` and `render` tags. */
globals?: object;
}
interface NormalizedOptions extends LiquidOptions {
@@ -56,9 +58,10 @@ export interface NormalizedFullOptions extends NormalizedOptions {
outputDelimiterLeft: string;
outputDelimiterRight: string;
greedy: boolean;
globals: object;
}
const defaultOptions: NormalizedFullOptions = {
export const defaultOptions: NormalizedFullOptions = {
root: ['.'],
cache: false,
extname: '',
@@ -73,7 +76,8 @@ const defaultOptions: NormalizedFullOptions = {
outputDelimiterLeft: '{{',
outputDelimiterRight: '}}',
strictFilters: false,
strictVariables: false
strictVariables: false,
globals: {}
}
export function normalize (options?: LiquidOptions): NormalizedOptions {