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

tempie

v0.0.2

Published

A delicious way to manage email templates.

Downloads

2

Readme

Tempie A Pie

A delicious way to manage email templates.

Tempie is nothing special when it comes to the actual templates. It utilizes handlebars to process HTML templates, which is well known and proven as far as templates go. What Tempie does provide is a flexible loading mechanism that allows you to organize your templates in several different ways. It will also handle compiling CSS into the HTML and generate a text-only version of the email.

Install

npm install tempie

Quick Start

Once installed, all you need to do is include it and save some template files.

var tempie = require('tempie');
//...some more code
var myEmail = tempie.load('newuser', userData, callback);
//myEmail
{
    "subject": "Welcome User!",
    "html": "<html><head>...</head><body>Welcome <em>Tony Stark</em>!</body></html>",
    "text": "Welcome Tony Stark!"
}

There are a few different ways you can organize your templates, but the preferred method is each template being in its own folder inside a templates directory. Each file must share the same name in order to be loaded.

You can also just throw all the files inside the templates directory if you find subfolders annoying. As long as the files have the same name, Tempie will find them in both cases.

The HTML and CSS files are self explanatory, with the HTML file being a handlebars template. Treat the template as the body of the HTML document, with the CSS file being added to a style tag in the head. A text-only version will also automatically generated from the processed template and added to the returned object.

The JSON file holds anything that you wish to be part of the email object returned when loaded. Typically these are things like the subject, the "from" email, etc. There is no restrictions and what you can add, but the only field that will currently be defaulted if not present is the subject.

{
    "subject": "Welcome User!"
}

If you prefer a single json configuration for all of your email templates, you can create an emails.json file in the templates root. Keep in mind this will not be reloaded on each load call, so you have to use separate JSON files for "hot loading" of new templates.

The only difference in structure is the emails.json requires the top-level to have the name of the template as the key.

{
    "newuser": {
        "subject": "Welcome User!"
    }
}