Skip to content

template/engines

Documentation

Overview

Classes

TemplateEngines

getDefaultEngine()

Retrieves the default template engine, which is currently the Velocity engine.

ts
static getDefaultEngine(): TemplateEngine;

Returns

  • Type: TemplateEngine
  • Description: The default template engine instance.

getMustacheEngine()

Retrieves the Mustache template engine instance. Mustache is often used for logic-less templating and uses ' and ' as default markers.

ts
static getMustacheEngine(): TemplateEngine;

Returns

  • Type: TemplateEngine
  • Description: The Mustache template engine instance.

getVelocityEngine()

Retrieves the Velocity template engine instance. Velocity is often used for complex templating with directives (e.g., #set, #foreach).

ts
static getVelocityEngine(): TemplateEngine;

Returns

  • Type: TemplateEngine
  • Description: The Velocity template engine instance.

getJavascriptEngine()

Retrieves the JavaScript template engine instance (usually used for server-side evaluation).

ts
static getJavascriptEngine(): TemplateEngine;

Returns

  • Type: TemplateEngine
  • Description: The JavaScript template engine instance.

generate()

Generates output by processing a raw template string using the default template engine (Velocity).

ts
static generate(location: string, template: string, parameters: any): string;
ParameterTypeDescription
locationstringA string identifying the template (used for error reporting/caching, often a file path).
templatestringThe raw template string content to process.
parametersanyAn object containing key-value pairs to be used as context variables in the template.

Returns

  • Type: string
  • Description: The processed output string.

generateFromFile()

Loads a template from the public registry, selects an appropriate engine, and generates output. It uses the Mustache engine if the file extension is `.mustache`, otherwise it uses the default (Velocity).

ts
static generateFromFile(location: string, parameters: any): string;
ParameterTypeDescription
locationstringThe path to the template file within the `/registry/public/` directory (e.g., 'templates/email.mustache').
parametersanyAn object containing key-value pairs to be used as context variables in the template.

Returns

  • Type: string
  • Description: The processed output string, or `undefined` if the resource does not exist.