From a0bd575055d6e00d3bfc4884aecc9de685a2f5ef Mon Sep 17 00:00:00 2001 From: Mick Charuwichitratana Date: Thu, 9 Nov 2017 18:44:47 +0700 Subject: [PATCH] Update swig-email-templates --- types/swig-email-templates/index.d.ts | 13 ++++++++-- .../swig-email-templates-tests.ts | 24 +++++++++---------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/types/swig-email-templates/index.d.ts b/types/swig-email-templates/index.d.ts index 26b5944053..2c28b03c5b 100644 --- a/types/swig-email-templates/index.d.ts +++ b/types/swig-email-templates/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for swig-email-templates // Project: https://github.com/andrewrk/swig-email-templates // Definitions by: Adam Babcock +// Satana Charuwichitratana // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -13,8 +14,16 @@ interface SwigRender { interface SwigEmailTemplatesOptions extends swig.SwigOptions { root?: string; + juice?: any; } -declare function init(options: SwigEmailTemplatesOptions, cb: (err: any, render: SwigRender) => 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; diff --git a/types/swig-email-templates/swig-email-templates-tests.ts b/types/swig-email-templates/swig-email-templates-tests.ts index de396909a6..2d74ebab14 100644 --- a/types/swig-email-templates/swig-email-templates-tests.ts +++ b/types/swig-email-templates/swig-email-templates-tests.ts @@ -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 - }); -});