Update swig-email-templates

This commit is contained in:
Mick Charuwichitratana
2017-11-09 18:44:47 +07:00
parent 841fcdaf10
commit a0bd575055
2 changed files with 23 additions and 14 deletions
+11 -2
View File
@@ -1,6 +1,7 @@
// Type definitions for swig-email-templates
// Project: https://github.com/andrewrk/swig-email-templates
// Definitions by: Adam Babcock <https://github.com/mrhen>
// Satana Charuwichitratana <https://github.com/micksatana>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="swig" />
@@ -13,8 +14,16 @@ interface SwigRender<T> {
interface SwigEmailTemplatesOptions extends swig.SwigOptions {
root?: string;
juice?: any;
}
declare function init<T>(options: SwigEmailTemplatesOptions, cb: (err: any, render: SwigRender<T>) => any): any;
export = init;
declare class EmailTemplates {
constructor(options?: SwigEmailTemplatesOptions);
generateText(templatePath: string, context: any, html: string, cb: Function): void;
generateSubject(templatePath: string, context: any, cb: Function): void;
rewriteUrls($: Function, rewrite: Function): void;
render(templatePath: string, context: any, cb: Function): void;
}
export = EmailTemplates;
@@ -1,15 +1,15 @@
import EmailTemplates = require('swig-email-templates');
import emailTemplates = require('swig-email-templates');
let templates = new EmailTemplates(),
withOptions = new EmailTemplates({ root: '' });
var options = {
root: "root"
};
templates.generateText('templatePath', {}, 'html', function () { });
templates.generateSubject('templatePath', {}, function () { });
templates.rewriteUrls(function () {}, function () {});
templates.render('templatePath', {}, function () { });
withOptions.generateText('templatePath', {}, 'html', function () { });
withOptions.generateSubject('templatePath', {}, function () { });
withOptions.rewriteUrls(function () {}, function () {});
withOptions.render('templatePath', {}, function () { });
emailTemplates(options, function(err, render) {
var context = {
meatballCount: 9001,
};
render('meatball-sandwich.html', context, function(err, html, text) {
// send html/text email
});
});