template-loader.ts 638 B

1234567891011121314151617181920
  1. import { LanguageCode } from '@vendure/common/lib/generated-types';
  2. import fs from 'fs-extra';
  3. import path from 'path';
  4. /**
  5. * Loads email templates according to the configured TemplateConfig values.
  6. */
  7. export class TemplateLoader {
  8. constructor(private templatePath: string) {}
  9. async loadTemplate(
  10. type: string,
  11. templateFileName: string,
  12. ): Promise<string> {
  13. // TODO: logic to select other files based on channel / language
  14. const templatePath = path.join(this.templatePath, type, templateFileName);
  15. const body = await fs.readFile(templatePath, 'utf-8');
  16. return body;
  17. }
  18. }