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
Properties
encoding
readonlyencoding:BufferEncoding
Defined in: src/loaders/file_system_loader.ts:56
fileExtension
readonlyfileExtension:string
Defined in: src/loaders/file_system_loader.ts:57
searchPath
readonlysearchPath: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
The active template environment.
name
string
A name or identifier for the target template.
context?
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
getSourceSync()
getSourceSync(
env,name,context?,options?):TemplateSource
Defined in: src/loaders/file_system_loader.ts:116
A synchronous version of getSource.
Parameters
env
name
string
context?
options?
Record<string, unknown>
Returns
See
Overrides
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
name
string
globals?
context?
options?
Record<string, unknown>
Returns
Promise<Template>
See
getSource. Override load to implement a caching loader.
Inherited from
loadSync()
loadSync(
env,name,globals?,context?,options?):Template
Defined in: src/loader.ts:95
A synchronous version of load.
Parameters
env
name
string
globals?
context?
options?
Record<string, unknown>
Returns
See
Inherited from
resolve()
protectedresolve(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()
protectedresolveSync(name): [string,number]
Defined in: src/loaders/file_system_loader.ts:183
A synchronous version of resolve.
Parameters
name
string
Returns
[string, number]
withFileExtension()
protectedwithFileExtension(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()
staticupToDate(templatePath,mtime):Promise<boolean>
Defined in: src/loaders/file_system_loader.ts:76
Parameters
templatePath
string
mtime
number
Returns
Promise<boolean>
upToDateSync()
staticupToDateSync(templatePath,mtime):boolean
Defined in: src/loaders/file_system_loader.ts:85
Parameters
templatePath
string
mtime
number
Returns
boolean