npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-angular-mail

v1.0.2

Published

NodeJS module to create HTML templates for mails using AngularJS syntax, along with Juice to get beautiful CSS injected directly into your generated templates

Downloads

6

Readme

node-angular-mail

NodeJS module to create beautiful mail templates using angularJS syntax, using Juice to inject CSS directly inline or from a file.

I needed to send mails via my NodeJS server, but creating static mails for each required case was not the optimal solution. Being a Frontend developer, I really liked the concept of AngularJS templates and hence, I was looking for solutions. Since I couldn't find the exact solution that I was looking for, I figured, I can merge multiple solutions to get what I wanted! So, here's node-angular-mail module, that requires angular-template module and juice module to create beautiful HTML mails with AngularJS templates, while allowing you to inject CSS, inline or from file. Right now, it performs following functions:

  • Take a AngularJS HTML string or file path, along with data and return final composed HTML with data injected into the template
  • Inject CSS style into the generated template, through inline CSS passed as string or a CSS file path

Installation

node-angular-mail requires Node.js v4+ to run. Also check the dependencies below (although, they're installed automatically when you install node-angular-mail)

Installing node-angular-mail should also install the dependencies, but just in case, you can also install dependencies separately as:

$ npm install angular-template --save
$ npm install juice --save

Then, install the module as

$ npm install node-angular-mail

Usage

After having the module installed, you need to generate html template first before you can inject CSS. Alternatively, you can pass on html string while calling up the CSS function to inject style. See below examples:

var nodeNgMail = require('node-angular-mail');
//set html template from file mails/welcome.html
var template = nodeNgMail.html.load('welcome.html', {user: {name: 'Amanda Waller'}});

//add CSS into loaded template
template = nodeNgMail.css.add("div{border: 1px solid green;}");

//add CSS from css files into loaded template
template = nodeNgMail.css.add('./test/style.css');
//template has the html template with rendered data and injected styles

//you can write the updated template to a file, or you can just send it in mail
var fs = require('fs');
fs.writeFile('./test/mail.html', template, function (err, result) {
    err ?console.log('Could not write template to file') :console.log('Added updated template to file!');
});

Dependencies

node-angular-mail requires following modules as dependency: Please note that NONE of the commands of these modules are

| Module | URL | | ------ | ------ | | angular-template | https://github.com/allenhwkim/angular-template | | Juice | https://github.com/Automattic/juice | Please note that NONE of the commands/functions of the above modules are supported directly by node-angular-mail module.

Todos

  • Provide access to parent modules

License

MIT

Free Software, Hell Yeah!