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

easymt

v0.0.1

Published

Simple email templates.

Downloads

2

Readme

Easy Mail Templates

EasyMT gives you a simple way to store and use email templates. Using ejs templates and some metadata, you can have email templates up and working in a matter of minutes. There are only a few steps to follow to get up and running.

Install

npm install easymt

Create Some Templates

You can store the templates anywhere you like, relative to the root of your app. By default, templates is used as the directory.

Each template needs two files, a metadata file and a tempalate file. Wherever you put them, they need to be stored in the same folder.

Metadata File

The metadata file is a JSON file and contains some needed metadata for your template. This is also where your define what template file will be used. An example template file might look something like this:

//mytemplate.json
{
  "subject": "This is an email!",
  "template": "mytemplate"
}

Currently, there are only two options. subject - The subject for the email. template - The name of the template file, minus the extension.

Template File

This is the actual EJS file. It follows all the rules for EJS templates, and should use the extension .ejs.

<!--mytemplate.ejs-->
<html>
  <body>
    <h1><%=heading%></h1>
  </body>
</html>

Use EasyMT

All you need to do now is include EasyMT and use it to get your template.

easymt.get(name, data, callback)

name - the name of the template, IE the filename of the template's metadata file. data - the data to pass to the template callback(err, template)

EasyMT will search for the metadata file then load in the template subject and body based on that metadata. Errors will be returned if the metadata or template file are not found.

var easymt = require('easymt');
easymt.get('mytemplate', {heading:'HELLO WORLD'}, function(err, template) {
  //use template
});

Each template object returned has the following properties available. subject - The subject loaded from the metadata body - The rendered body of the template.

easymt.init(templateDir, options)

templateDir - Directory (relative to the application root) that the template files are stored in. options - The EJS options to pass when rendering the template.

Using the init function is optional, but allows you to setup a few things you may want to be customized. Calling it during the require call is the easiest way to set things up.

var easymt = require('easymt').init('path/to/templates', {open:'{{',close:'}}'});