# elemailtempgen

> Email template generator

Latest version **1.0.14** (published 2023-11-16) · GPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install elemailtempgen
pnpm add elemailtempgen
yarn add elemailtempgen
bun add elemailtempgen
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.14 |
| Published | 2023-11-16 |
| First published | 2023-05-25 |
| Weekly downloads | 0 |
| License | GPL-3.0-or-later |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=v14.0 |
| Dependencies | 3 |
| Unpacked size | 256.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | lei |
| Maintainers | eldanamo |
| Keywords | emailtemp |

## Links

- npm: https://www.npmjs.com/package/elemailtempgen
- Repository: https://github.com/leahfkd/elemailtempgen
- Homepage: https://github.com/leahfkd/elemailtempgen#readme
- Issues: https://github.com/leahfkd/elemailtempgen/issues
- npm.io page: https://npm.io/package/elemailtempgen

## Dependencies (3)

- [fs](https://npm.io/package/fs.md) ^0.0.1-security
- [mustache](https://npm.io/package/mustache.md) ^4.2.0
- [commander](https://npm.io/package/commander.md) ^11.1.0

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.0.14 (latest) — 2023-11-16
- 1.0.13 — 2023-11-14
- 1.0.12 — 2023-10-18
- 1.0.11 — 2023-10-18
- 1.0.10 — 2023-09-17
- 1.0.9 — 2023-09-16
- 1.0.8 — 2023-08-14
- 1.0.7 — 2023-07-04
- 1.0.6 — 2023-05-26
- 1.0.5 — 2023-05-26
- 1.0.4 — 2023-05-25
- 1.0.3 — 2023-05-25
- 1.0.2 — 2023-05-25
- 1.0.1 — 2023-05-25
- 1.0.0 — 2023-05-25

## 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
```bash
  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`
   &emsp; Type: String
   `secondary`
   &emsp; Type: String
###### `font`
Type: String
Accepted value:Arvo, sans-serif, Arial, monospace

---
_Source: https://npm.io/package/elemailtempgen · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
