@brilab-mailer/template-handlebars
v0.0.2-12
Published
This package provides a Handlebars-powered template rendering engine fully compatible with the Brilab Mailer architecture.
Downloads
2,650
Readme
@brilab-mailer/template-handlebars
Overview
This package provides a Handlebars-powered template rendering engine fully compatible with the Brilab Mailer architecture.
It implements:
export interface MailerTemplateEngine {
render(templateName: string, context: unknown): Promise<string>;
}Features
- Layout support
- Partials
- Helpers
- Async rendering
- Template caching
Folder Structure Recommendation
templates/
welcome.hbs
reset-password.hbs
layouts/
main.hbs
partials/
footer.hbs
header.hbsUsage in MailerModule
MailerModule.register({
providerClass: MailtrapApiProvider,
templateEngineClass: HandlebarsTemplateEngine,
});Example Template
templates/welcome.hbs
<h1>Hello {{name}}!</h1>
<p>Welcome to our platform.</p>Example Render Call
const html = await this.mailer.render('welcome', { name: 'John' });Performance
- Precompilation optional
- Lazy loading template files
- Cache invalidation on demand
Best Practices
- Avoid complex helper logic
- Use layouts for branding consistency
- Store templates outside the src folder in production
