Class: Context

Hierarchy

  • Context

Constructors

constructor

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

Defined in src/context/context.ts:34

Parameters:

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

Returns: Context

Properties

environments

environments: Scope

Defined in src/context/context.ts:21

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:25

global scope used as fallback for missing variables


opts

opts: NormalizedFullOptions

Defined in src/context/context.ts:30

The normalized liquid options object


Private registers

registers: object

Defined in src/context/context.ts:15

Type declaration:


Private scopes

scopes: Scope[] = [{}]

Defined in src/context/context.ts:14

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


strictVariables

strictVariables: boolean

Defined in src/context/context.ts:34

Throw when accessing undefined variable?


sync

sync: boolean

Defined in src/context/context.ts:26

Methods

_get

_get(paths: PropertyKey[]): IterableIterator‹unknown›

Defined in src/context/context.ts:64

Parameters:

Name Type
paths PropertyKey[]

Returns: IterableIterator‹unknown›


_getFromScope

_getFromScope(scope: unknown, paths: PropertyKey[] | string): IterableIterator‹unknown›

Defined in src/context/context.ts:74

Parameters:

Name Type
scope unknown
paths PropertyKey[] | string

Returns: IterableIterator‹unknown›


bottom

bottom(): Scope

Defined in src/context/context.ts:90

Returns: Scope


Private findScope

findScope(key: string | number): Scope

Defined in src/context/context.ts:93

Parameters:

Name Type
key string | number

Returns: Scope


get

get(paths: PropertyKey[]): unknown

Defined in src/context/context.ts:61

deprecated use _get() instead

Parameters:

Name Type
paths PropertyKey[]

Returns: unknown


getAll

getAll(): Scope

Defined in src/context/context.ts:54

Returns: Scope


getFromScope

getFromScope(scope: unknown, paths: PropertyKey[] | string): IterableIterator‹unknown›

Defined in src/context/context.ts:71

deprecated use _get() instead

Parameters:

Name Type
scope unknown
paths PropertyKey[] | string

Returns: IterableIterator‹unknown›


getRegister

getRegister(key: string): any

Defined in src/context/context.ts:42

Parameters:

Name Type
key string

Returns: any


pop

pop(): undefined | ScopeObject‹› | Drop‹›

Defined in src/context/context.ts:87

Returns: undefined | ScopeObject‹› | Drop‹›


push

push(ctx: object): number

Defined in src/context/context.ts:84

Parameters:

Name Type
ctx object

Returns: number


restoreRegister

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

Defined in src/context/context.ts:51

Parameters:

Name Type
keyValues [string, any][]

Returns: void


saveRegister

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

Defined in src/context/context.ts:48

Parameters:

Name Type
...keys string[]

Returns: [string, any][]


setRegister

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

Defined in src/context/context.ts:45

Parameters:

Name Type
key string
value any

Returns: any