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

elemailtempgen

v1.0.14

Published

Email template generator

Downloads

30

Readme

Email template generator ( WORKING IN PROGRESS)

Generates email templates for the following modules with set of mustache placeholder.

  • button
  • datacard
  • description
  • image
  • label
  • table
  • chart see https://www.image-charts.com/blog/create-chart-with-one-url

Installation

  npm install elemailtempgen

Example to include the package to project file:

const emailhelper = require('elemailtempgen');

Usage/Examples

Without custom key

This generate template with default keys

emailhelper.getModTemplate(modulename);

Example:

const nocustomkey = emailhelper.getModTemplate('label');

console.log(nocustomkey);

Above command will result to a single module hmtl content structure with mustache placeholder {{{modLabel.content}}}.


To attach modules in a whole html document format, you may use:

emailhelper.processAllTemplates(['label']);

For multiple modules you can process it by:

emailhelper.processAllTemplates(['label','button']);

With custom key

To generate template with custom keys:

emailhelper.getModTemplate(modulename,customkey);

Example:

const modulewithcustomkey = emailhelper.getModTemplate('label','label_id1' );

console.log(modulewithcustomkey);

It will generate module html with mustache placeholder like

{{{label_id1.content}}}

This process is the same when you want to create template already attached to a whole html content.

Example:

const modulestogeneratewithkeys = [
  {key:'label_id1', module: 'label'}
  , {key:'button_id1', module: 'button'}
];

const htmlcontent = emailhelper.processAllTemplates(modulestogeneratewithkeys);

console.log(htmlcontent);

List of all available modules and their info

| module | available object nodes | Default key | | :-----: | :---: | :---: | | button | label, href, bgcolor | modButton | | label | content, bgcolor, fontsize , fontcolor | modLabel | | datacard | label, subLabel, imageLink, cardNumber | modDatacard | | description | content, fontcolor, bgcolor | modDescription | | image | src, bgcolor, width | modImage | | chart | src | modChart | | href | link, label | modHref | | table | columns, rows, bgcolor | modTable |

Module table additional objects for columns and rows

array of title

Example:

const moduleobjects = {
  modTable: {
   rows: [
     [ {title: "Lei"}, {title:"29"} ]
     , [ {title: "John"}, {title:"30"} ]
   ],
   columns: [ { title:"Name" }, { title: "Age"}]
 }
}

This will generate a table that looks like (Note Display is based on default table display placed here) | Name | Age | | :-----: | :---: | | Lei | 29 | | John | 30 |

How available objects nodes and keys are use in actual

Using module button

{
 label: '',
 href: '',
 bgcolor:''
}

If you have default key, the package will generate below mustache placeholder

  • modButton.label
  • modButton.href
  • modButton.bgcolor

If you have custom key the modButton will replaced with supplied custom key

Full example for default key:

const emailhelper = require('elemailtempgen')
const mustache = require('mustache');


const htmlwithbutton = emailhelper.processAllTemplates(['button']);

const mustacheobj = {
  modButton: {
    label: 'Hello World',
    href: 'https://www.youtube.com',
    bgcolor:'red'
  }
}

const html = mustache.render(htmlwithbutton, mustacheobj)
console.log(html);

Full example for custom key:

const emailhelper = require('elemailtempgen')
const mustache = require('mustache');


const modulestogeneratewithkeys = [
  {key:'button_id1', module: 'button'}
];
const htmlwithbutton = emailhelper.processAllTemplates(modulestogeneratewithkeys);

const mustacheobj = {
  button_id1: {
    label: 'Hello World',
    href: 'https://www.youtube.com',
    bgcolor:'red'
  }
}

const html = mustache.render(htmlwithbutton, mustacheobj)
console.log(html);

Other mustache object or options

Themes

Main object node/key: theme
colors

Type: Object Items: primary, secondary primary   Type: String secondary   Type: String

font

Type: String Accepted value:Arvo, sans-serif, Arial, monospace