25 releases (14 stable)

1.2.11 Jan 11, 2023
1.2.10 Mar 25, 2022
1.2.7 Jan 29, 2022
1.2.6 Oct 8, 2021
0.2.0 Jun 8, 2020

#5 in Email

Download history 6095/week @ 2022-10-14 5831/week @ 2022-10-21 5881/week @ 2022-10-28 6081/week @ 2022-11-04 5880/week @ 2022-11-11 5790/week @ 2022-11-18 6046/week @ 2022-11-25 5979/week @ 2022-12-02 5896/week @ 2022-12-09 5653/week @ 2022-12-16 5293/week @ 2022-12-23 3147/week @ 2022-12-30 8267/week @ 2023-01-06 16182/week @ 2023-01-13 15871/week @ 2023-01-20 13863/week @ 2023-01-27

55,011 downloads per month
Used in 2 crates

Custom license

445KB
12K SLoC

MRML

Crates.io Crates.io

.github/workflows/main.yml codecov

Average time to resolve an issue Percentage of issues still open Maintainability

Introduction

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

How to use it in my code

Update your cargo.toml:

[dependencies]
mrml = "1.2"
serde = { version = "1.0", features = ["derive"] }

Create your main.rs:

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.js server rendering an MJML template takes around 20 MB of RAM at startup and 130 MB under stress test. In Rust, less than 1.7 MB at startup and a bit less that 3 MB under stress test. The Rust version can also handle twice as many requests per second. You can perform the benchmarks by running bash script/run-bench.sh.
  • The JavaScript implementation cannot be run in the browser; the Rust one (and WebAssembly one) can be.

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: 606.59ms
  • Rust: 3.48ms

Missing implementations

  • mj-style[inline]: not yet implemented. It requires parsing the generated html to apply the inline styles afterward (that's how it's done in mjml) which would kill the performances. Applying it at render time would improve the performance but it would still require to parse the CSS.
  • mj-include: not yet implemented. It requires to handle loading remote templates when using mrml in a wasm (browser or server side) format, which implies being able to load from a different location (file://, https://, relative, etc).

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.

What is using MRML?

mjml_nif - Elixir library

mrml-ruby - Ruby library

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.

You want to sponsor us?

Buy Me A Coffee

Thanks to zachzurn.

Dependencies

~0–485KB
~10K SLoC