Skip to main content

Interface: ITemplateEngine

Defined in: Services/ITemplateEngine.ts:6

Interface for template rendering engines. Allows swapping between different template engines (LiquidJS, Handlebars, etc.) while keeping the same API.

Methods

registerFilter()

registerFilter(name, fn): void

Defined in: Services/ITemplateEngine.ts:23

Registers a custom filter/helper that can be used in templates.

Parameters

name

string

The name of the filter/helper

fn

(...args) => unknown

The function that implements the filter/helper

Returns

void


render()

render(templateString, data): Promise<string>

Defined in: Services/ITemplateEngine.ts:15

Renders a template string with the provided data.

Parameters

templateString

string

The template text containing placeholders and logic

data

Record<string, unknown>

The data object to use when rendering the template

Returns

Promise<string>

A promise that resolves to the rendered HTML string

Throws

Error if the template is invalid or rendering fails


validateTemplate()

validateTemplate(templateString): boolean

Defined in: Services/ITemplateEngine.ts:31

Validates that a template string is syntactically correct.

Parameters

templateString

string

The template text to validate

Returns

boolean

true if valid, false otherwise