template/engines
Documentation
- source: template/engines.ts
Overview
Classes
TemplateEngines
getDefaultEngine()
Retrieves the default template engine, which is currently the Velocity engine.
tsstatic 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.
tsstatic 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).
tsstatic getVelocityEngine(): TemplateEngine;Returns
- Type:
TemplateEngine- Description: The Velocity template engine instance.
getJavascriptEngine()
Retrieves the JavaScript template engine instance (usually used for server-side evaluation).
tsstatic 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).
tsstatic generate(location: string, template: string, parameters: any): string;
Parameter Type Description 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).
tsstatic generateFromFile(location: string, parameters: any): string;
Parameter Type Description 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.
