UNPKG

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