Class: Context

Hierarchy

  • Context

Constructors

constructor

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

Defined in src/context/context.ts:33

Parameters:

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

Returns: Context

Properties

environments

environments: Scope

Defined in src/context/context.ts:20

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

global scope used as fallback for missing variables


opts

opts: NormalizedFullOptions

Defined in src/context/context.ts:29

The normalized liquid options object


Private registers

registers: object

Defined in src/context/context.ts:14

Type declaration:


Private scopes

scopes: Scope[] = [{}]

Defined in src/context/context.ts:13

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


strictVariables

strictVariables: boolean

Defined in src/context/context.ts:33

Throw when accessing undefined variable?


sync

sync: boolean

Defined in src/context/context.ts:25

Methods

bottom

bottom(): Scope

Defined in src/context/context.ts:77

Returns: Scope


Private findScope

findScope(key: string): Scope

Defined in src/context/context.ts:80

Parameters:

Name Type
key string

Returns: Scope


get

get(paths: string[]): object

Defined in src/context/context.ts:57

Parameters:

Name Type
paths string[]

Returns: object


getAll

getAll(): Scope

Defined in src/context/context.ts:53

Returns: Scope


getFromScope

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

Defined in src/context/context.ts:61

Parameters:

Name Type
scope object
paths string[] | string

Returns: object


getRegister

getRegister(key: string): any

Defined in src/context/context.ts:41

Parameters:

Name Type
key string

Returns: any


pop

pop(): undefined | PlainObject | Drop‹›

Defined in src/context/context.ts:74

Returns: undefined | PlainObject | Drop‹›


push

push(ctx: object): number

Defined in src/context/context.ts:71

Parameters:

Name Type
ctx object

Returns: number


restoreRegister

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

Defined in src/context/context.ts:50

Parameters:

Name Type
keyValues [string, any][]

Returns: void


saveRegister

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

Defined in src/context/context.ts:47

Parameters:

Name Type
...keys string[]

Returns: [string, any][]


setRegister

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

Defined in src/context/context.ts:44

Parameters:

Name Type
key string
value any

Returns: any