Parcourir la source

feat(email-plugin): Expose template vars to template loader (#2243)

Closes #2242
Serge Morel il y a 2 ans
Parent
commit
78ea016551

+ 1 - 1
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);
      }
 }

+ 1 - 0
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);

+ 1 - 0
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 {