Class: FetchLoader
Defined in: src/loaders/fetch_loader.ts:69
A template loader that fetches templates using the Fetch API.
This is an async only loader. Expect an error when using this
loader with getSourceSync() and Environment.getTemplateSync().
This loader treats the response body as text that is the template source code. You might need to write a custom loader to handle JSON responses, for example.
Extends
Constructors
Constructor
new FetchLoader(
baseURL,options?):FetchLoader
Defined in: src/loaders/fetch_loader.ts:81
The FetchLoader constructor. Creates a new FetchLoader.
Parameters
baseURL
string
The base URL from which to fetch templates from.
options?
FetchLoaderOptions = {}
Loader options. Most of which are passed
through to the Fetch API's Request constructor.
Returns
FetchLoader
Overrides
Properties
baseURL
readonlybaseURL:string
Defined in: src/loaders/fetch_loader.ts:70
Methods
getSource()
getSource(
env,name):Promise<TemplateSource>
Defined in: src/loaders/fetch_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.
Returns
Promise<TemplateSource>
Overrides
getSourceSync()
getSourceSync():
TemplateSource
Defined in: src/loaders/fetch_loader.ts:102
A synchronous version of getSource.
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>