Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tpl-emails

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tpl-emails

Generate HTML emails using templating engine

  • 2.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

tpl-emails

Build Status NPM version

Generate HTML emails using templating engine (nunjuncks by default). Inspired by andrewrk/swig-email-templates.

Features

  • Uses nunjucks, which supports Django-inspired template inheritance. You can provide your render method.
  • Uses juice, which takes an HTML file and inlines all the <link rel="stylesheet">s and the <style>s.
  • URL rewrite support - you can provide a urlRewrite option to rewrite your links.
  • Text emails - for a template name passed into render(), if a file exists with the same name but a .txt extension it will be rendered separately. If the .txt file does not exist, html-to-text will auto-generate a text version of the html file. This can be disabled with the option text: false.

Usage

var path = require('path');
var TplEmails = require("tpl-emails");

var emails = new TplEmails({
    root: path.join(__dirname, "templates")
});

emails.render('meatball-sandwich.html', { context: { meatballCount: 9001 } }, function(err, html, text) {
    // send html/text email
});

Use your own templating engine

For example to use underscore/lodash templating engine:

var fs = require("fs");
var _ = require("lodash");
var TplEmails = require("tpl-emails");

var emails = new TplEmails({
    render: function(tplname, context, callback) {
        var content = fs.readFileSync("templates/"+tplname);
        callback(null, _.template(content, context));
    }
});

emails.render('meatball-sandwich.html', { context: { meatballCount: 9001 } }, function(err, html, text) {
    // send html/text email
});

FAQs

Package last updated on 03 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc