UNPKG

2.03 kBTypeScriptView Raw
1import { NormalizedFullOptions, RenderOptions } from '../liquid-options';
2import { Scope } from './scope';
3type PropertyKey = string | number;
4export declare class Context {
5 /**
6 * insert a Context-level empty scope,
7 * for tags like `{% capture %}` `{% assign %}` to operate
8 */
9 private scopes;
10 private registers;
11 /**
12 * user passed in scope
13 * `{% increment %}`, `{% decrement %}` changes this scope,
14 * whereas `{% capture %}`, `{% assign %}` only hide this scope
15 */
16 environments: Scope;
17 /**
18 * global scope used as fallback for missing variables
19 */
20 globals: Scope;
21 sync: boolean;
22 /**
23 * The normalized liquid options object
24 */
25 opts: NormalizedFullOptions;
26 /**
27 * Throw when accessing undefined variable?
28 */
29 strictVariables: boolean;
30 ownPropertyOnly: boolean;
31 constructor(env?: object, opts?: NormalizedFullOptions, renderOptions?: RenderOptions);
32 getRegister(key: string): any;
33 setRegister(key: string, value: any): any;
34 saveRegister(...keys: string[]): [string, any][];
35 restoreRegister(keyValues: [string, any][]): void;
36 getAll(): Scope;
37 /**
38 * @deprecated use `_get()` or `getSync()` instead
39 */
40 get(paths: PropertyKey[]): unknown;
41 getSync(paths: PropertyKey[]): unknown;
42 _get(paths: PropertyKey[]): IterableIterator<unknown>;
43 /**
44 * @deprecated use `_get()` instead
45 */
46 getFromScope(scope: unknown, paths: PropertyKey[] | string): IterableIterator<unknown>;
47 _getFromScope(scope: unknown, paths: PropertyKey[] | string, strictVariables?: boolean): IterableIterator<unknown>;
48 push(ctx: object): number;
49 pop(): Scope | undefined;
50 bottom(): Scope;
51 private findScope;
52}
53export declare function readProperty(obj: Scope, key: PropertyKey, ownPropertyOnly: boolean): any;
54export declare function readJSProperty(obj: Scope, key: PropertyKey, ownPropertyOnly: boolean): any;
55export {};