davisford / swig-emails

Generate HTML emails using swig templates

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

swig-emails

Build Status NPM version

Generate HTML emails using swig templates. Inspired by andrewrk/swig-email-templates.

Features

  • Uses swig, which supports Django-inspired template inheritance. You can provide yoru own swig instance.
  • 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 SwigEmails = require("swig-emails");

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

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

About

Generate HTML emails using swig templates

License:Apache License 2.0


Languages

Language:JavaScript 42.8%Language:HTML 34.7%Language:CSS 22.5%