Skip to content

JamesClow/Vue-MJML

Repository files navigation

Introduction

This project is a Node.js server for generating dynamic emails using Vue.js and MJML. The basic idea is to use Vue's server-side renderer to populate an MJML template with data. Then the MJML can easily be compiled into HTML.

Getting Started

  1. Clone the project
  2. Use Node v12.0.0
  3. Install npm packages
  4. Run the server

Run the Server

node index.js

You can test it out by sending a Post request to http://localhost:7576 with the following:

{
  "data": {
    "client_name": "Your Name",
    "orders": [
      {
        "number": "1234567890",
        "date": "1/1/3000",
        "total": "$1,000,000"
      },{
        "number": "0987654321",
        "date": "1/1/3000",
        "total": "$5,000,000"
      }
    ],
    "receipt_link": "https://mjml.io",
    "tracking_link": "https://mjml.io"
  },
  "template": "purchase_receipt"
}

Note: The server requires two properties to be present in the object, data, and template. The data object is used to populate Vue's app data. The template string specifies which MJML template to use. In this case, it will use the template located at "./campaigns/purchase_receipt.mjml".

Run the Dev Server

 npm --path="./testData/sample.json" run serve

Note: You can change the path to point to other test data sets.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published