Skip to main content

TemplateLoader

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

Example

Ts
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>

Load template and return it's content as a string

loadPartials

method() => Promise<Partial[]>

Load partials and return their contents. This method is only called during initialization, i.e. during server startup.

Loads email templates from the local file system. This is the default loader used by the EmailPlugin.

Signature
class FileBasedTemplateLoader implements TemplateLoader {    constructor(templatePath: string)    loadTemplate(_injector: Injector, _ctx: RequestContext, { type, templateName }: LoadTemplateInput) => Promise<string>;    loadPartials() => Promise<Partial[]>;}

constructor

method(templatePath: string) => FileBasedTemplateLoader

loadTemplate

method(_injector: Injector, _ctx: RequestContext, { type, templateName }: LoadTemplateInput) => Promise<string>

loadPartials

method() => Promise<Partial[]>
Was this chapter helpful?
Report Issue
Edited Feb 2, 2026·Edit this page