Skip to main content

TemplateEngine

@webda/templates


Interface: TemplateEngine

Defined in: packages/templates/src/itemplate.ts:31

Template engine contract

Properties​

extensions​

extensions: string[]

Defined in: packages/templates/src/itemplate.ts:35

File extensions handled by the engine (without the dot)

Methods​

compile()​

compile(source, options?): CompiledTemplate | Promise<CompiledTemplate>

Defined in: packages/templates/src/itemplate.ts:46

Compile a template source

Parameters​

source​

string

the template source

options?​

TemplateRenderOptions

compile options

Returns​

CompiledTemplate | Promise<CompiledTemplate>


configure()?​

optional configure(options): void | Promise<void>

Defined in: packages/templates/src/itemplate.ts:40

Configure the engine

Parameters​

options​

any

engine specific options

Returns​

void | Promise<void>


load()?​

optional load(path, options?): Promise<CompiledTemplate>

Defined in: packages/templates/src/itemplate.ts:52

Optional: load a template from its path instead of readFile + compile (module-based engines, e.g. tsx)

Parameters​

path​

string

the template path

options?​

TemplateRenderOptions

compile options

Returns​

Promise<CompiledTemplate>


parts()?​

optional parts(path, options?): Promise<string[]>

Defined in: packages/templates/src/itemplate.ts:60

Optional: list the parts a single file provides (e.g. html, subject, text), making the engine multi-part

The renderer then calls load with the requested part and gives no partials

Parameters​

path​

string

the template path

options?​

TemplateRenderOptions

compile options

Returns​

Promise<string[]>