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

@travetto/email-template

v3.1.19

Published

Email templating module

Downloads

68

Readme

Email Templating

Email templating module

Install: @travetto/email-template

npm install @travetto/email-template

# or

yarn add @travetto/email-template

This is primarily a set of command line tools for compiling and developing templates. The inputs are compiled files, generally under the support/ folder, that represents the necessary input for the email compilation. Email Inky Templates shows this pattern by leveraging JSX bindings for the inky framework, allowing for compile-time checked templates.

Asset Management

The templating process involves loading various assets (html, css, images), and so there is provision for asset management and loading. The templating config allows for specifying asset paths, with the following paths (in order of precedence):

  1. %ROOT%/resources/email
  2. @travetto/email-{engine}/resources/email When looking up a resources, every asset folder is consulted, in order, and the first to resolve an asset wins. This allows for overriding of default templating resources, as needed. The compilation process will convert .email.html files into .compiled.html, .compiled.text and .compiled.subject suffixes to generate the outputs respectively.

Template Extension

The template extension points are defined at:

  1. email/main.scss - The entry point for adding, and overriding any sass
  2. email/{engine}.wrapper.html - The html wrapper for the specific templating engine implementation.

Template Compilation

The general process is as follows:

  1. Load in the email template.
  2. Resolve any associated stylings for said template.
  3. Render template into html, text, and subject outputs.
  4. Inline and optimize all images for html email transmission.

Images

When referencing an image from the resources folder in a template, e.g.

Code: Sample Image Reference

<img src="/email/logo.png">

The image will be extracted out and embedded in the email as a multi part message. This allows for compression and optimization of images as well as externalizing resources that may not be immediately public. The currently supported set of image types are:

  • jpeg
  • png

Template Development

The module provides Command Line Interface and VSCode plugin support for email template development.

CLI Compilation

The module provides Command Line Interface support for email template compilation also. Running

Terminal: Running template compilation

$ trv email:compile -h

Usage: email:compile [options]

Options:
  -w, --watch            Compile in watch mode
  -m, --module <string>  Module to run for
  -h, --help             display help for command

Will convert all .email.html files into the appropriate .compiled.html, .compiled.text and .compiled.subject files. These will be used during the running of the application. By default these files are added to the .gitignore as they are generally not intended to be saved but to be generated during the build process.

VSCode Plugin

In addition to command line tools, the VSCode plugin also supports:

  • automatic compilation on change
  • real-time rendering of changes visually
  • ability to send test emails during development
  • ability to define custom context for template rendering