• Stars
    star
    350
  • Rank 121,229 (Top 3 %)
  • Language
    HTML
  • License
    MIT License
  • Created over 4 years ago
  • Updated 26 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
139
star
2

jolimail

Send nice emails
TypeScript
135
star
3

docker-activity

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

git-metrics

A git extension to be able to track metrics about your project, within the git repository
Rust
35
star
5

magic-link-example

JavaScript
31
star
6

ferris-emoji

Set of ferris emojis πŸ¦€
31
star
7

docker-on-ci

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

loopback-component-storage-mongo

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

docker-with-buildx

Docker image with buildx preinstalled
Dockerfile
16
star
10

tmdb-api

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

tekitoi

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

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
13

expo-image-cache-example

JavaScript
10
star
14

awesome-docker-cli-plugins

😎 Awesome lists of docker cli plugins
9
star
15

serde-toml-merge

Merge your toml configurations in rust
Rust
7
star
16

manteau

Just an alternative to Jackett, but fast and light πŸ§₯
HTML
6
star
17

loopback-component-sqlizer

Component to add sql methods to models
CoffeeScript
6
star
18

traduit

Traduction tool
JavaScript
5
star
19

postgres-querybuilder

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

dockerfiles

Shell
5
star
21

pcloud

Rust client for pCloud API
Rust
4
star
22

mrml-editor

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

action-git-metrics

Github action for git-metrics
4
star
24

article-queue-like-a-boss

JavaScript
3
star
25

powercap

Rust crate that helps read powercap data
Rust
3
star
26

opencv-wasm

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

rusty-board

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

docker-bug-value-too-long

Reporting a docker buildx bug
Rust
2
star
29

datadog-client

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

kaamelott-quote

JavaScript
1
star
31

deadpool-lettre

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

webapp-gulp-builder

CoffeeScript
1
star
33

jolimail.io

landing page for jolimail
TypeScript
1
star
34

tiny-vector

Just an experiment of rewriting vector, from scratch, without looking at the code, for fun and learning.
Rust
1
star
35

mini-agent

Almost like Vector but not really
Rust
1
star
36

quiestce

Simple oauth mock written in Rust
Rust
1
star
37

mailbunny

Forward the email βœ‰οΈ you receive to a rabbitmq exchange 🐰
JavaScript
1
star
38

normal-it

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

emscripten-images

Images of emscripten modules
Dockerfile
1
star
40

kind-testing

Trying to run containers, in kubernetes, inside a container 🀯
Shell
1
star
41

rust-bench

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

mouchard

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

opengraph-html-webpack-plugin

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

loopback-presentation

HTML
1
star
45

expo-image-cache

JavaScript
1
star
46

donos

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

docker-gatsby

Image to build gatsby project
Makefile
1
star
48

tokio-postgres-migration

Library to run migrations
Rust
1
star
49

htmlparser

Rust
1
star