drupal/mjml_render_bin

Standalone MJML to HTML renderer with pre-built binaries. No Node.js required at runtime.

Maintainers

Package info

git.drupalcode.org/project/mjml_render_bin.git

Type:composer-plugin

pkg:composer/drupal/mjml_render_bin

Statistics

Installs: 22

Dependents: 0

Suggesters: 0

1.0.0-beta5 2026-04-27 18:54 UTC

README

Standalone MJML to HTML renderer with pre-built binaries. No Node.js required at runtime.

Installation

composer require drupal/mjml_render_bin

The Composer plugin automatically detects your platform and downloads the correct MJML binary during installation.

Supported Platforms

PlatformArchitecture
Linuxx64
LinuxARM64 (Not yet supported by CI)
macOS (Darwin)x64
macOS (Darwin)ARM64 (Not yet supported by CI)

Usage

use Drupal\mjml_render_bin\MjmlBinaryRenderer;

$renderer = new MjmlBinaryRenderer();

$html = $renderer->render('
<mjml>
  <mj-body>
    <mj-section>
      <mj-column>
        <mj-text>Hello World</mj-text>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>
');

Custom Binary Path

Pass a custom binary path to the constructor:

$renderer = new MjmlBinaryRenderer('/path/to/custom/mjml');

When used with the drupal/mjml_render_engine module, configure the path in settings.php or settings.local.php:

$settings['mjml_render_bin.path'] = '/path/to/custom/mjml';

Building a Custom Binary

Use Docker to build an MJML binary without installing Node.js locally:

# Build the latest MJML binary for Linux x64
docker run --rm -v $(pwd)/custom-bin:/output node:22-alpine sh -c \
  "npm install -g mjml @yao-pkg/pkg && \
   pkg \$(which mjml) -t node22-linuxstatic-x64 -o /output/mjml"

# Build a specific MJML version (e.g., 4.15.3)
docker run --rm -v $(pwd)/custom-bin:/output node:22-alpine sh -c \
  "npm install -g mjml@4.15.3 @yao-pkg/pkg && \
   pkg \$(which mjml) -t node22-linuxstatic-x64 -o /output/mjml"

# Build for macOS ARM64 (Apple Silicon)
docker run --rm -v $(pwd)/custom-bin:/output node:22-alpine sh -c \
  "npm install -g mjml @yao-pkg/pkg && \
   pkg \$(which mjml) -t node22-macos-arm64 -o /output/mjml"

Then configure the path as described above.

How It Works

This package uses a branching strategy to deliver platform-specific binaries without bloating the main package:

  • The main branch contains only PHP code (~50KB)
  • Stable tags (e.g., 1.0.0) are created on the main branch
  • Platform branches (e.g., 1.0.0-linux-x64) contain the compiled binary
  • When you composer require drupal/mjml_render_bin:^1.0, Composer installs the lightweight 1.0.0 tag from main
  • The Composer plugin detects your platform and downloads the binary from the matching platform-suffixed branch (e.g., 1.0.0-linux-x64)

Assisted By

Initial release made possible with the assistance of Claude Opus 4.6 and Gemini 3.1 Pro.

License

GPL-2.0-or-later