Skip to main content

Custom Template Loader

TemplateLoader

Load an email template based on the given request context, type and template name and return the template as a string.

Example

import { EmailPlugin, TemplateLoader } from '@vendure/email-plugin';

class MyTemplateLoader implements TemplateLoader {
loadTemplate(injector, ctx, { type, templateName }){
return myCustomTemplateFunction(ctx);
}
}

// In vendure-config.ts:
...
EmailPlugin.init({
templateLoader: new MyTemplateLoader()
...
})
Signature
interface TemplateLoader {
loadTemplate(injector: Injector, ctx: RequestContext, input: LoadTemplateInput): Promise<string>;
loadPartials?(): Promise<Partial[]>;
}

loadTemplate

method
(injector: Injector, ctx: RequestContext, input: LoadTemplateInput) => Promise<string>

loadPartials

method
() => Promise<Partial[]>