#email #mjml

mrml

Rust implementation of MJML renderer

10 unstable releases (3 breaking)

new 0.4.0 Oct 24, 2020
0.3.3 Oct 14, 2020
0.2.0 Jun 8, 2020
0.1.3 Jun 6, 2020
0.1.1 May 30, 2020

#25 in Email

Download history 5/week @ 2020-07-04 10/week @ 2020-07-11 19/week @ 2020-07-18 2/week @ 2020-07-25 21/week @ 2020-08-01 63/week @ 2020-08-08 78/week @ 2020-08-15 139/week @ 2020-08-22 96/week @ 2020-08-29 87/week @ 2020-09-05 80/week @ 2020-09-12 87/week @ 2020-09-19 92/week @ 2020-09-26 126/week @ 2020-10-03 145/week @ 2020-10-10 125/week @ 2020-10-17

380 downloads per month
Used in mrml-cli

Custom license

300KB
8K SLoC

MRML

Crates.io Crates.io

Build Status codecov

Maintainability

Introduction

This project is a reimplementation of the nice MJML markup language in Rust.

How to use it

use mrml;

fn main() {
    match mrml::to_html("<mjml><mj-body></mj-body></mjml>", mrml::Options::default()) {
        Ok(content) => println!("{}", content),
        Err(_) => println!("couldn't convert mjml template"),
    };
}

Why?

  • A Node server rendering a mjml template takes around 20Mo of RAM at startup and 130Mo under stress test. In Rust, less than 1.7Mo at startup and a bit less that 3Mo under stress test. The Rust version can also handle 2 times more requests per seconds. You can run the bench by doing bash script/run-bench.sh.
  • The JS implementation cannot be run in the browser. In Rust (and Wasm), you can.

You want to contribute?

Feel free to read our contributing section and the code of conduct.

Performance

With the same linux amd64 machine, to render the amario template

  • Node: 62.803ms
  • Rust: 13.180ms

To reproduce those results:

  • Node, in example/mjml-bench run npm start -- ../../test/template-amario.mjml
  • Rust, run cargo bench amario

With a web server, as of today, on a mac book pro from 2017. (Old result) | | Rust | Node | | ---------------------- | ------ | -------- | | Requests per seconds | 520.50 | 272.61 | | CPU usage at boot time | 0.20% | 1.74% | | CPU usage under bench | 49.81% | 136.83% | | RAM usage at boot time | 1.12MB | 17.27MB | | RAM usage under bench | 2.85MB | 128.32MB | | Docker image size | 77.3MB | 178MB |

Dependencies

~2MB
~50K SLoC