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

inky-email-render-to-string

v0.0.2

Published

use foundation email template builder programmatically

Downloads

3

Readme

foundation-email-process-output

use foundation inky v2 email template builder programmatically. Provide data and receive a string back.

alt tag

install

npm install inky-email-render-to-string

usage

instanciate the class with the path to email templates folder. Then you can use the produceMail method with parameters to output a promise with the email as a string. You can render several email templates as long as they share the same default layout.

const InkyMailOutput = require('inky-email-render-to-string');

// create instance with relative root path to template assets folder
let instance = new InkyMailOutput('email-template');

// provide mail (template, conf, data) --> return processed email as promise
let templateName = 'basic';

// respective folders (see Inky/Panini Docs) + mail subject
let emailConfig = {
    root: 'pages',
    layouts: 'layouts',
    partials: 'partials',
    helpers: 'helpers',
    css: 'css/app.css',
    subject: 'My Basic Email Template Subject'
};

// all data to populate the email template
let emailData = {
    title: 'Hi, Susan Calvin',
    content: {
        lead: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Magni, iste, amet consequatur a veniam.',
        body: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ut optio nulla et, fugiat. Maiores accusantium nostrum asperiores provident, quam modi ex inventore dolores id aspernatur architecto odio minima perferendis, explicabo. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima quos quasi itaque beatae natus fugit provident delectus, magnam laudantium odio corrupti sit quam. Optio aut ut repudiandae velit distinctio asperiores?',
        callout: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Reprehenderit repellendus natus, sint ea optio dignissimos asperiores inventore a molestiae dolorum placeat repellat excepturi mollitia ducimus unde doloremque ad, alias eos!'
    }
};

// render email and rceive promise based email string
instance.produceMail(templateName, emailConfig, emailData).then(
    function(resp) { 
        console.log('successful email render', resp); 
    },
    function(error) { console.log(error); }
);

Note: the email-template folder is provided as a sample based on Foundation email template. You can delete it and provide your own. Remember to modify the config accordingly.

Changelog

v0.0.2

  • no need to pass data folder property in emailConfig. It is setup automatically.
  • fixed root path calculation when used as dependency package