From 78ea016551e6c999d66d2933db9d107948ba5bfe Mon Sep 17 00:00:00 2001 From: Serge Morel <79153163+StampixSMO@users.noreply.github.com> Date: Wed, 28 Jun 2023 16:53:40 +0200 Subject: [PATCH] feat(email-plugin): Expose template vars to template loader (#2243) Closes #2242 --- .../core-plugins/email-plugin/custom-template-loader.md | 2 +- packages/email-plugin/src/email-processor.ts | 1 + packages/email-plugin/src/types.ts | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/content/typescript-api/core-plugins/email-plugin/custom-template-loader.md b/docs/content/typescript-api/core-plugins/email-plugin/custom-template-loader.md index b567293733..69a60cfe39 100644 --- a/docs/content/typescript-api/core-plugins/email-plugin/custom-template-loader.md +++ b/docs/content/typescript-api/core-plugins/email-plugin/custom-template-loader.md @@ -24,7 +24,7 @@ and return the template as a string. import { EmailPlugin, TemplateLoader } from '@vendure/email-plugin'; class MyTemplateLoader implements TemplateLoader { - loadTemplate(injector, ctx, { type, templateName }){ + loadTemplate(injector, ctx, { type, templateName, templateVars }){ return myCustomTemplateFunction(ctx); } } diff --git a/packages/email-plugin/src/email-processor.ts b/packages/email-plugin/src/email-processor.ts index d57c242e18..298dff4104 100644 --- a/packages/email-plugin/src/email-processor.ts +++ b/packages/email-plugin/src/email-processor.ts @@ -81,6 +81,7 @@ export class EmailProcessor { { templateName: data.templateFile, type: data.type, + templateVars: data.templateVars, }, ); const generated = this.generator.generate(data.from, data.subject, bodySource, data.templateVars); diff --git a/packages/email-plugin/src/types.ts b/packages/email-plugin/src/types.ts index a36df7f66b..f9e96476c4 100644 --- a/packages/email-plugin/src/types.ts +++ b/packages/email-plugin/src/types.ts @@ -354,6 +354,7 @@ export interface EmailTemplateConfig { export interface LoadTemplateInput { type: string; templateName: string; + templateVars: any; } export interface Partial {