Skip to main content

Class: NodeFileSystemLoader

A template loader that reads templates from a file system when deployed to the NodeJS runtime.

Extends

Constructors

new NodeFileSystemLoader()

new NodeFileSystemLoader(searchPath, options): NodeFileSystemLoader

The NodeFileSystemLoader constructor. Create a new NodeFileSystemLoader.

Parameters

searchPath: string | string[]

A path, or array of paths, to search for templates.

options: NodeFileSystemLoaderOptions = {}

Loader options.

Returns

NodeFileSystemLoader

Overrides

Loader.constructor

Defined in

src/builtin/loaders/file_system_loader.ts:65

Properties

encoding

readonly encoding: BufferEncoding

Defined in

src/builtin/loaders/file_system_loader.ts:55


fileExtension

readonly fileExtension: string

Defined in

src/builtin/loaders/file_system_loader.ts:56


searchPath

readonly searchPath: string[]

Defined in

src/builtin/loaders/file_system_loader.ts:57

Methods

getSource()

getSource(name): Promise<TemplateSource>

Override getSource to implement a custom loader.

Parameters

name: string

The name or identifier of a template.

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/file_system_loader.ts:75


getSourceSync()

getSourceSync(name): TemplateSource

A synchronous version of getSource.

Parameters

name: string

Returns

TemplateSource

See

getSource

Overrides

Loader.getSourceSync

Defined in

src/builtin/loaders/file_system_loader.ts:81


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.

Inherited from

Loader.load

Defined in

src/loader.ts:76


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

Inherited from

Loader.loadSync

Defined in

src/loader.ts:97


resolve()

protected resolve(name): Promise<string>

Find the path to the template file with the given name.

Parameters

name: string

A template file name relative to one of the paths in the current search path.

Returns

Promise<string>

The template file name joined with the first path in the configured search path that is a file.

Throws

TemplateNotFoundError If a file with the given name can not be found.

Defined in

src/builtin/loaders/file_system_loader.ts:112


resolveSync()

protected resolveSync(name): string

A synchronous version of resolve.

Parameters

name: string

Returns

string

Defined in

src/builtin/loaders/file_system_loader.ts:131


withFileExtension()

protected withFileExtension(name): string

Append the default file extension if the given template name does not have one.

Parameters

name: string

A template file name relative to one of the paths in the current search path.

Returns

string

The argument name with the default file extension, if it did not already have one.

Defined in

src/builtin/loaders/file_system_loader.ts:97