UNPKG

ts-mailer

Version:

This lib provide a class and function as singleton instance to compile a hbs template adding data and send it as an email using aws-ses. ## Send email using hbs template and aws-ses

34 lines 1.57 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TemplateCompiler = void 0; const fs_1 = require("fs"); const handlebars_1 = __importDefault(require("handlebars")); const tsyringe_1 = require("tsyringe"); let TemplateCompiler = class TemplateCompiler { compileTemplate(hbs, variable) { const handlebar = handlebars_1.default.create(); const template = handlebar.compile(hbs); return template(Object.assign({}, variable)); } exists(path) { return (0, fs_1.existsSync)(path); } getTemplate(path) { return (0, fs_1.readFileSync)(path, 'utf-8'); } }; TemplateCompiler = __decorate([ (0, tsyringe_1.singleton)() ], TemplateCompiler); exports.TemplateCompiler = TemplateCompiler; exports.default = TemplateCompiler; //# sourceMappingURL=template-compiler.js.map