#email #mjml

mrml

Rust implementation of MJML renderer

16 releases (5 stable)

new 1.2.2 May 15, 2021
1.2.0 Apr 21, 2021
0.5.0 Jan 31, 2021
0.4.0 Oct 24, 2020
0.2.0 Jun 8, 2020

#6 in Email

Download history 167/week @ 2021-01-21 257/week @ 2021-01-28 269/week @ 2021-02-04 555/week @ 2021-02-11 430/week @ 2021-02-18 4276/week @ 2021-02-25 5513/week @ 2021-03-04 5445/week @ 2021-03-11 5422/week @ 2021-03-18 5550/week @ 2021-03-25 5342/week @ 2021-04-01 5373/week @ 2021-04-08 5476/week @ 2021-04-15 5396/week @ 2021-04-22 5597/week @ 2021-04-29 4923/week @ 2021-05-06

20,648 downloads per month
Used in mrml-cli

Custom license

435KB
12K 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 in the cli

# installing mrml-cli
cargo install mrml-cli
# using it 
mrml-cli path/to/template.mjml validate
mrml-cli path/to/template.mjml render
mrml-cli path/to/template.mjml format-json --pretty
mrml-cli path/to/template.json format-mjml --pretty
# getting some help
mrml-cli --help

How to use it in my code

use mrml;

fn main() {
    let root = mrml::parse("<mjml><mj-body></mj-body></mjml>").expect("parse template");
    let opts = mrml::prelude::render::Options::default();
    match root.render(&opts) {
        Ok(content) => println!("{}", content),
        Err(_) => println!("couldn't render 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 -- ../../resources/template-amario.mjml
  • Rust, run cargo bench amario

Who is using MRML?

If you are using MRML and want to be added to this list, don't hesitate to create an issue or open a pull request.

Dependencies

~0–310KB