Class: Context

Hierarchy

  • Context

Constructors

constructor

+ new Context(env: object, opts: NormalizedFullOptions, renderOptions: RenderOptions): Context

Defined in src/context/context.ts:35

Parameters:

Name Type Default
env object {}
opts NormalizedFullOptions defaultOptions
renderOptions RenderOptions {}

Returns: Context

Properties

environments

environments: Scope

Defined in src/context/context.ts:22

user passed in scope
{% increment %}, {% decrement %} changes this scope,
whereas {% capture %}, {% assign %} only hide this scope


globals

globals: Scope

Defined in src/context/context.ts:26

global scope used as fallback for missing variables


opts

opts: NormalizedFullOptions

Defined in src/context/context.ts:31

The normalized liquid options object


Private registers

registers: object

Defined in src/context/context.ts:16

Type declaration:


Private scopes

scopes: Scope[] = [{}]

Defined in src/context/context.ts:15

insert a Context-level empty scope,
for tags like {% capture %} {% assign %} to operate


strictVariables

strictVariables: boolean

Defined in src/context/context.ts:35

Throw when accessing undefined variable?


sync

sync: boolean

Defined in src/context/context.ts:27

Methods

bottom

bottom(): Scope

Defined in src/context/context.ts:79

Returns: Scope


Private findScope

findScope(key: string | number): Scope

Defined in src/context/context.ts:82

Parameters:

Name Type
key string | number

Returns: Scope


get

get(paths: PropertyKey[]): object

Defined in src/context/context.ts:59

Parameters:

Name Type
paths PropertyKey[]

Returns: object


getAll

getAll(): Scope

Defined in src/context/context.ts:55

Returns: Scope


getFromScope

getFromScope(scope: object, paths: PropertyKey[] | string): object

Defined in src/context/context.ts:63

Parameters:

Name Type
scope object
paths PropertyKey[] | string

Returns: object


getRegister

getRegister(key: string): any

Defined in src/context/context.ts:43

Parameters:

Name Type
key string

Returns: any


pop

pop(): undefined | Drop‹› | PlainObject

Defined in src/context/context.ts:76

Returns: undefined | Drop‹› | PlainObject


push

push(ctx: object): number

Defined in src/context/context.ts:73

Parameters:

Name Type
ctx object

Returns: number


restoreRegister

restoreRegister(keyValues: [string, any][]): void

Defined in src/context/context.ts:52

Parameters:

Name Type
keyValues [string, any][]

Returns: void


saveRegister

saveRegister(…keys: string[]): [string, any][]

Defined in src/context/context.ts:49

Parameters:

Name Type
...keys string[]

Returns: [string, any][]


setRegister

setRegister(key: string, value: any): any

Defined in src/context/context.ts:46

Parameters:

Name Type
key string
value any

Returns: any