Skip to main content

Class: NodeFileSystemLoader

Defined in: src/loaders/file_system_loader.ts:55

A template loader that reads template source text from files on a file system using the Node.js fs API.

Extends

Extended by

Constructors

Constructor

new NodeFileSystemLoader(searchPath, __namedParameters?): NodeFileSystemLoader

Defined in: src/loaders/file_system_loader.ts:60

Parameters

searchPath

string | string[]

__namedParameters?

NodeFileSystemLoaderOptions = {}

Returns

NodeFileSystemLoader

Overrides

TemplateLoader.constructor

Properties

encoding

readonly encoding: BufferEncoding

Defined in: src/loaders/file_system_loader.ts:56


fileExtension

readonly fileExtension: string

Defined in: src/loaders/file_system_loader.ts:57


searchPath

readonly searchPath: string[]

Defined in: src/loaders/file_system_loader.ts:58

Methods

getSource()

getSource(env, name, context?, options?): Promise<TemplateSource>

Defined in: src/loaders/file_system_loader.ts:93

Load template source text and meta data.

Parameters

env

Environment

The active template environment.

name

string

A name or identifier for the target template.

context?

RenderContext

The current render context, if one is available.

options?

Record<string, unknown>

Arbitrary options that can be used to narrow the template search space.

Returns

Promise<TemplateSource>

Overrides

TemplateLoader.getSource


getSourceSync()

getSourceSync(env, name, context?, options?): TemplateSource

Defined in: src/loaders/file_system_loader.ts:116

A synchronous version of getSource.

Parameters

env

Environment

name

string

context?

RenderContext

options?

Record<string, unknown>

Returns

TemplateSource

See

getSource

Overrides

TemplateLoader.getSourceSync


load()

load(env, name, globals?, context?, options?): Promise<Template>

Defined in: src/loader.ts:75

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

Parameters

env

Environment

name

string

globals?

Namespace

context?

RenderContext

options?

Record<string, unknown>

Returns

Promise<Template>

See

getSource. Override load to implement a caching loader.

Inherited from

TemplateLoader.load


loadSync()

loadSync(env, name, globals?, context?, options?): Template

Defined in: src/loader.ts:95

A synchronous version of load.

Parameters

env

Environment

name

string

globals?

Namespace

context?

RenderContext

options?

Record<string, unknown>

Returns

Template

See

load

Inherited from

TemplateLoader.loadSync


resolve()

protected resolve(name): Promise<[string, number]>

Defined in: src/loaders/file_system_loader.ts:164

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, number]>

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.


resolveSync()

protected resolveSync(name): [string, number]

Defined in: src/loaders/file_system_loader.ts:183

A synchronous version of resolve.

Parameters

name

string

Returns

[string, number]


withFileExtension()

protected withFileExtension(name): string

Defined in: src/loaders/file_system_loader.ts:149

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.


upToDate()

static upToDate(templatePath, mtime): Promise<boolean>

Defined in: src/loaders/file_system_loader.ts:76

Parameters

templatePath

string

mtime

number

Returns

Promise<boolean>


upToDateSync()

static upToDateSync(templatePath, mtime): boolean

Defined in: src/loaders/file_system_loader.ts:85

Parameters

templatePath

string

mtime

number

Returns

boolean