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 - }); -});