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

sendgrid-dynamic-templates

v1.2.0

Published

Tool to generate dynamic templates and upload to Sendgrid

Downloads

47

Readme

Sengrid Dynamic Templates Bulk Updater

This tool helps you generate and upload Sendgrid Dynamic Templates in bulk.

If your system has more than a few templates, likely they all share the same header/footer and only the content is different.

What do you do when your logo or footer url changes? This tool to the rescue!

$ SENDGRID_API_KEY=your-api-key
$ yarn upload
The template directory is set to /Users/ddikman/code/sendgrid-dynamic-templates/templates. Is this correct? (y/n) y
Do you want to increase the version? (y/n) y
Enter the new version name: Aug-22 Footer update
Skipping non-HTML file: some-other-file.txt
Template [Login email] (d-a2176d95113e410caf19c145dc5e5882) version [Aug-22 Footer update] created

Usage

  1. You need to either add a .env file or set the SENDGRID_API_KEY in the current terminal.
  2. Then add your html templates into the templates/ folder, named by the ID of the template you have
  3. Run yarn upload and answer the prompts

I recommend you start with just a single template file in the templates/ directory to see if everything works as expected. You might even want to create a new template first and test with.

Command line tools

You can also install this globally and use it as a pure command line tool:

npm install -g sendgrid-dynamic-templates
download-sendgrid-templates
generate-sendgrid-templates
upload-sendgrid-templates

Or using npx to install if it isn't installed already.

API Key requirements

For the API key, it only requires the Template Engine permissions so you can keep it slim reduce the risk.

Only Template Engine permissions are required

Generating template files

Although you can use this tool by just placing your email templates in the templates/ folder and use only the upload function, you will likely want to generate your email templates using layouts as well.

You do this by adding your template layout in layouts/your-template.html and then your emails, prefixed with the template name in emails/your-template_d-123xxx.html.

When you run yarn generate that will loop through all emails in the emails/ folder and output them to templates/ replacing the <!-- EMAIL CONTENT --> with the contents of your email.

Downloading existing templates

To make things even easier, you can also download the templates you have created already. For example, if someone manually updates one of the templates, you can use this tool to download all existing templates for the next bulk update. Just run yarn download or npx download-sendgrid-templates.

Please note that this action is destructive, it will overwrite any local templates.

Limitations

You must have the template created in Sendgrid first with a version.

When downloading the templates, they will be as-they-are, meaning any previously applied template will have to be manually stripped and the layout name updated.