Class: Context

Hierarchy

  • Context

Constructors

constructor

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

Defined in src/context/context.ts:36

Parameters:

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

Returns: Context

Properties

environments

environments: Scope

Defined in src/context/context.ts:23

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

global scope used as fallback for missing variables


opts

opts: NormalizedFullOptions

Defined in src/context/context.ts:32

The normalized liquid options object


Private registers

registers: object

Defined in src/context/context.ts:17

Type declaration:


Private scopes

scopes: Scope[] = [{}]

Defined in src/context/context.ts:16

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


strictVariables

strictVariables: boolean

Defined in src/context/context.ts:36

Throw when accessing undefined variable?


sync

sync: boolean

Defined in src/context/context.ts:28

Methods

_get

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

Defined in src/context/context.ts:66

Parameters:

Name Type
paths PropertyKey[]

Returns: IterableIterator‹unknown›


_getFromScope

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

Defined in src/context/context.ts:76

Parameters:

Name Type
scope unknown
paths PropertyKey[] | string

Returns: IterableIterator‹unknown›


bottom

bottom(): Scope

Defined in src/context/context.ts:92

Returns: Scope


Private findScope

findScope(key: string | number): Scope

Defined in src/context/context.ts:95

Parameters:

Name Type
key string | number

Returns: Scope


get

get(paths: PropertyKey[]): unknown

Defined in src/context/context.ts:63

deprecated use _get() instead

Parameters:

Name Type
paths PropertyKey[]

Returns: unknown


getAll

getAll(): Scope

Defined in src/context/context.ts:56

Returns: Scope


getFromScope

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

Defined in src/context/context.ts:73

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

Parameters:

Name Type
key string

Returns: any


pop

pop(): undefined | Drop‹› | PlainObject

Defined in src/context/context.ts:89

Returns: undefined | Drop‹› | PlainObject


push

push(ctx: object): number

Defined in src/context/context.ts:86

Parameters:

Name Type
ctx object

Returns: number


restoreRegister

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

Defined in src/context/context.ts:53

Parameters:

Name Type
keyValues [string, any][]

Returns: void


saveRegister

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

Defined in src/context/context.ts:50

Parameters:

Name Type
...keys string[]

Returns: [string, any][]


setRegister

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

Defined in src/context/context.ts:47

Parameters:

Name Type
key string
value any

Returns: any