Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mattmezza/email-lang

The email language
https://github.com/mattmezza/email-lang

compiler email language model transpiler

Last synced: 5 days ago
JSON representation

The email language

Awesome Lists containing this project

README

        

# SYNOPSIS
_A language to model emails._

You can use this software in your npm project by requiring it or you can use [email-lang-cli](https://github.com/mattmezza/email-lang-cli) from your command line.

# BUILD

[![Travis](https://img.shields.io/travis/mattmezza/email-lang.svg)]()

```bash
npm install --save-dev email-lang
```

# USAGE

### email.txt
Write an email file that follows the language specification

```
From: "matteomerola.me"
Subject: Comment about the novel
Date: February 21, 2017 at 7:02:47 AM GMT+1
To: Tiffany
Reply-To: Matteo

We all know the numerous film adaptations of the novel!

Cheers,
Matt.
```

### index.js
Create an instance of the model then pass data into it one or more times.

```js
const fs = require('fs')
const compile = require('email-lang')

let emails = compile(fs.readFileSync('email.txt', 'utf8'))

console.log(emails[0].subject) // prints "Comment about the novel"
```

### output

The result will be an array of emails structured as follows

```js
[
{
from: {
name: 'Matteo',
email: '[email protected]'
},
subject: 'The subject of the email',
to: {
name: 'Recipient',
email: '[email protected]'
},
replyTo: {
name: 'Matteo',
email: '[email protected]'
},
text: 'The body content of the email message'
},
{
...// another email if any
}
]
```

# LICENSE

http://matteomerola.me

[![License](https://img.shields.io/npm/l/array.from.svg)](/LICENSE)