diff --git a/types/email-templates/email-templates-tests.ts b/types/email-templates/email-templates-tests.ts
index 3c4493402c..a3311d6e81 100644
--- a/types/email-templates/email-templates-tests.ts
+++ b/types/email-templates/email-templates-tests.ts
@@ -1,29 +1,14 @@
import EmailTemplates = require('email-templates');
-const EmailTemplate = EmailTemplates.EmailTemplate;
-const template = new EmailTemplate("./");
-const templateWithOptions = new EmailTemplate('./', {disableJuice: true, sassOptions: {}, juiceOptions: {}});
-const users = [
- {
- email: 'pappa.pizza@spaghetti.com',
- name: {
- first: 'Pappa',
- last: 'Pizza'
- }
+const email = new EmailTemplates({
+ message: {
+ from: 'Test@tesitng.com'
},
- {
- email: 'mister.geppetto@spaghetti.com',
- name: {
- first: 'Mister',
- last: 'Geppetto'
- }
- }
-];
+ transport: {
+ jsonTransport: true
+ }}
+);
-const templates = users.map((user) => {
- return template.render(user)
- .then((results) => {
- const {html, subject, text} = results;
- return html;
- });
-});
+email.juiceResources('
bob
');
+email.render('mars/html.pug', {name: 'elon'});
+email.send({template: 'mars', message: {to: 'elon@spacex.com'}, locals: {name: 'Elon'}});
diff --git a/types/email-templates/index.d.ts b/types/email-templates/index.d.ts
index 754a06877d..12dceb181d 100644
--- a/types/email-templates/index.d.ts
+++ b/types/email-templates/index.d.ts
@@ -1,113 +1,104 @@
-// Type definitions for node-email-templates 2.6
+// Type definitions for node-email-templates 3.1
// Project: https://github.com/niftylettuce/node-email-templates
// Definitions by: Cyril Schumacher
// Matus Gura
+// Jacob Copeland
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-export interface EmailTemplateResults {
- html: string;
- text: string;
- subject: string;
+interface EmailConfig {
+ /**
+ * The message
+ */
+ message: any;
+ /**
+ * The nodemailer Transport created via nodemailer.createTransport
+ */
+ transport: any;
+ /**
+ * The email template directory and engine information
+ */
+ views?: any;
+ /**
+ * Do you really want to send, false for test or development
+ */
+ send?: boolean;
+ /**
+ * Preview the email
+ */
+ preview?: boolean;
+ /**
+ * Set to object to configure and Enable
+ */
+ i18n?: any;
+ /**
+ * Pass a custom render function if necessary
+ */
+ render?: { view: string, locals: any };
+ /**
+ *
+ */
+ htmlToText?: any;
+ /**
+ *
+ */
+ juice?: boolean;
+ /**
+ *
+ */
+ juiceResources?: any;
}
-export type EmailTemplateCallback = (err: any, results: EmailTemplateResults) => void;
-
-export interface EmailTemplateOptions {
- disableJuice?: boolean;
- juiceOptions?: any;
- sassOptions?: any;
+interface EmailOptions {
+ /**
+ * The template name
+ */
+ template: string;
+ /**
+ * Nodemailer Message
+ */
+ message: any;
+ /**
+ * The Template Variables
+ */
+ locals: any;
}
-export class EmailTemplate {
+declare class EmailTemplate {
+ constructor(config: EmailConfig);
/**
- * @param templateDir The template directory.
+ * shorthand use of `juiceResources` with the config
+ * mainly for custom renders like from a database).
*/
- constructor(templateDir: string, options?: EmailTemplateOptions);
-
+ juiceResources(html: string): Promise ;
/**
- * Render a single template.
- * @param locals The template variables.
- * @param locale The language code.
+ *
+ * @param view The Html pug to render
+ * @param locals The template Variables
*/
- render(locals: any, locale?: string): Promise;
-
+ render(view: string, locals: any): Promise;
/**
- * Render a single template.
+ * Send the Email
*/
- render(callback: EmailTemplateCallback): void;
-
- /**
- * Render a single template.
- * @param locals The template variables.
- */
- render(locals: any, callback: EmailTemplateCallback): void;
-
- /**
- * Render a single template.
- * @param locals The template variables.
- * @param locale The language code.
- */
- render(locals: any, locale: string, callback: EmailTemplateCallback): void;
-
- /**
- * Render text
- * @param locals The template variables.
- * @param locale The language code.
- */
- renderText(locals: any, locale?: string): Promise;
-
- /**
- * Render text
- * @param locals The template variables.
- * @param callback The language code.
- */
- renderText(locals: any, callback: EmailTemplateCallback): void;
-
- /**
- * Render text
- * @param locals The template variables.
- * @param locale The language code.
- * @param callback The language code.
- */
- renderText(locals: any, locale: string, callback: EmailTemplateCallback): void;
-
- /**
- * Render subject
- * @param locals The template variables.
- * @param locale The language code.
- */
- renderSubject(locals: any, locale?: string): Promise;
-
- /**
- * Render subject
- * @param locals The template variables.
- */
- renderSubject(locals: any, callback: EmailTemplateCallback): void;
-
- /**
- * Render subject
- * @param locals The template variables.
- * @param locale The language code.
- */
- renderSubject(locals: any, locale: string, callback: EmailTemplateCallback): void;
-
- /**
- * Render HTML
- * @param locals The template variables.
- * @param locale The language code.
- */
- renderHtml(locals: any, locale?: string): Promise;
-
- /**
- * Render HTML
- * @param locals The template variables.
- */
- renderHtml(locals: any, callback: EmailTemplateCallback): void;
-
- /**
- * Render HTML
- * @param locals The template variables.
- * @param locale The language code.
- */
- renderHtml(locals: any, locale: string, callback: EmailTemplateCallback): void;
+ send(options: EmailOptions): any;
}
+
+declare namespace EmailTemplate {
+ /**
+ * shorthand use of `juiceResources` with the config
+ * mainly for custom renders like from a database).
+ */
+ function juiceResources(html: string): Promise ;
+
+ /**
+ *
+ * @param view The Html pug to render
+ * @param locals The template Variables
+ */
+ function render(view: string, locals: any): Promise;
+
+ /**
+ * Send the Email
+ */
+ function send(options: EmailOptions): any;
+}
+export = EmailTemplate;