• Stars
    star
    310
  • Rank 130,399 (Top 3 %)
  • Language
    HTML
  • License
    MIT License
  • Created about 4 years ago
  • Updated 9 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Implementation of mjml in rust

MRML

Crates.io Crates.io FOSSA Status

.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"),
    };
}

Available options are:

Name Comment Default value
disable_comments Strip comments out of rendered HTML false
social_icon_origin Custom URL for fetching social icons None
fonts Default fonts imported in the HTML rendered by MJML See default options

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

mjml-python - Python 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.

License

FOSSA Status

More Repositories

1

catapulte

Rust implementation of catapulte email sender
Rust
135
star
2

jolimail

Send nice emails
TypeScript
133
star
3

docker-activity

Tool to monitor the statistics and the energy consumption of docker containers
Rust
52
star
4

magic-link-example

JavaScript
31
star
5

docker-on-ci

Examples of how to use docker on different CIs
Makefile
29
star
6

loopback-component-storage-mongo

A loopback component storage to store in mongo
CoffeeScript
29
star
7

ferris-emoji

Set of ferris emojis 🦀
27
star
8

docker-with-buildx

Docker image with buildx preinstalled
Dockerfile
15
star
9

tmdb-api

Yet another TMDB api client written in rust, working with async
Rust
13
star
10

tekitoi

A lightweight and easy to use oauth2 proxy
Rust
12
star
11

loopback-component-storage-postgres

LoopBack storage postgres component provides Node.js and REST APIs to manage binary contents using Postgres Large Object
CoffeeScript
11
star
12

expo-image-cache-example

JavaScript
10
star
13

awesome-docker-cli-plugins

😎 Awesome lists of docker cli plugins
8
star
14

loopback-component-sqlizer

Component to add sql methods to models
CoffeeScript
6
star
15

manteau

Just an alternative to Jackett, but fast and light 🧥
HTML
5
star
16

traduit

Traduction tool
JavaScript
5
star
17

postgres-querybuilder

A query builder for postgres written in Rust
Rust
5
star
18

dockerfiles

Shell
5
star
19

pcloud

Rust client for pCloud API
Rust
4
star
20

serde-toml-merge

Merge your toml configurations in rust
Rust
4
star
21

mrml-editor

A component to edit mjml in the browser
TypeScript
4
star
22

article-queue-like-a-boss

JavaScript
3
star
23

powercap

Rust crate that helps read powercap data
Rust
3
star
24

opencv-wasm

Try to build opencv in wasm, just keeping what I need
C++
3
star
25

rusty-board

It's like Trello, but written in rust and open source.
2
star
26

docker-bug-value-too-long

Reporting a docker buildx bug
Rust
2
star
27

datadog-client

Rust implementation of a client to the datadog api
Rust
2
star
28

kaamelott-quote

JavaScript
1
star
29

deadpool-lettre

This crate implements a deadpool manager for lettre
Rust
1
star
30

webapp-gulp-builder

CoffeeScript
1
star
31

jolimail.io

landing page for jolimail
TypeScript
1
star
32

normal-it

Normalizes and denormalizes JSON according to relational schema
JavaScript
1
star
33

emscripten-images

Images of emscripten modules
Dockerfile
1
star
34

kind-testing

Trying to run containers, in kubernetes, inside a container 🤯
Shell
1
star
35

mouchard

Microservice to know if the recipient opened your email
Rust
1
star
36

opengraph-html-webpack-plugin

Let wepback generate all your opengraph informations for you
JavaScript
1
star
37

loopback-presentation

HTML
1
star
38

expo-image-cache

JavaScript
1
star
39

donos

Like Pi-Hole but without many things (like the UI) and written in Rust
Rust
1
star
40

mailbunny

Forward the email ✉️ you receive to a rabbitmq exchange 🐰
JavaScript
1
star
41

rust-bench

Should I do it this way or that way? Write a bench!
Rust
1
star
42

docker-gatsby

Image to build gatsby project
Makefile
1
star
43

tokio-postgres-migration

Library to run migrations
Rust
1
star