Skip to main content

Class: ChoiceLoader

A template loader that will try each of an array of loaders until a template is found, or throw a TemplateNotFoundError if none of the loaders could find the template.

Extends

Constructors

new ChoiceLoader()

new ChoiceLoader(loaders): ChoiceLoader

Parameters

loaders: Loader[]

Returns

ChoiceLoader

Overrides

Loader.constructor

Defined in

src/builtin/loaders/choice_loader.ts:18

Properties

loaders

readonly loaders: Loader[]

Defined in

src/builtin/loaders/choice_loader.ts:18

Methods

getSource()

getSource(): Promise<TemplateSource>

Override getSource to implement a custom loader.

Returns

Promise<TemplateSource>

The source, with any meta data, for the template identified by the given name

Throws

TemplateNotFoundError Thrown if the template can not be found.

Overrides

Loader.getSource

Defined in

src/builtin/loaders/choice_loader.ts:22


getSourceSync()

getSourceSync(): TemplateSource

A synchronous version of getSource.

Returns

TemplateSource

See

getSource

Overrides

Loader.getSourceSync

Defined in

src/builtin/loaders/choice_loader.ts:27


load()

load(name, environment, context?, globals?, loaderContext?): Promise<Template>

Used internally by Environment.getTemplate(). Delegates to getSource.

Parameters

name: string

environment: Environment

context?: RenderContext

globals?: ContextScope

loaderContext?

Returns

Promise<Template>

See

getSource. Override load to implement a caching loader.

Overrides

Loader.load

Defined in

src/builtin/loaders/choice_loader.ts:33


loadSync()

loadSync(name, environment, context?, globals?, loaderContext?): Template

A synchronous version of load.

Parameters

name: string

environment: Environment

context?: RenderContext

globals?: ContextScope

loaderContext?

Returns

Template

See

load

Overrides

Loader.loadSync

Defined in

src/builtin/loaders/choice_loader.ts:58