@brilab-mailer/template-handlebars 0.0.1-beta.51 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,7 +3,7 @@ import { Inject, Injectable } from '@nestjs/common';
|
|
|
3
3
|
import { MAILER_TEMPLATE_ENGINE_OPTIONS, } from '@brilab-mailer/contracts';
|
|
4
4
|
import * as fs from 'fs';
|
|
5
5
|
import * as path from 'path';
|
|
6
|
-
import
|
|
6
|
+
import handlebars from 'handlebars';
|
|
7
7
|
let HandlebarsTemplateEngine = class HandlebarsTemplateEngine {
|
|
8
8
|
options;
|
|
9
9
|
templatesDir;
|
|
@@ -22,14 +22,14 @@ let HandlebarsTemplateEngine = class HandlebarsTemplateEngine {
|
|
|
22
22
|
throw new Error(`Template not found: ${filePath}`);
|
|
23
23
|
}
|
|
24
24
|
const source = fs.readFileSync(filePath, 'utf8');
|
|
25
|
-
return compile(source);
|
|
25
|
+
return handlebars.compile(source);
|
|
26
26
|
}
|
|
27
27
|
loadLayout(key) {
|
|
28
28
|
const filePath = path.join(this.layoutsDir, `${key}.hbs`);
|
|
29
29
|
if (!fs.existsSync(filePath))
|
|
30
30
|
return null;
|
|
31
31
|
const source = fs.readFileSync(filePath, 'utf8');
|
|
32
|
-
return compile(source);
|
|
32
|
+
return handlebars.compile(source);
|
|
33
33
|
}
|
|
34
34
|
async render(templateKey, context = {}, options = { layoutKey: 'default' }) {
|
|
35
35
|
const template = this.loadTemplate(templateKey);
|