UNPKG

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