drupal / mjml_render_bin
Standalone MJML to HTML renderer with pre-built binaries. No Node.js required at runtime.
Package info
git.drupalcode.org/project/mjml_render_bin.git
Type:composer-plugin
pkg:composer/drupal/mjml_render_bin
Requires
- php: >=8.3
- composer-plugin-api: ^2.0
Requires (Dev)
- composer/composer: ^2.0
- phpunit/phpunit: ^10.5 || ^11.0
This package is auto-updated.
Last update: 2026-04-27 18:15:06 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
| Platform | Architecture |
|---|---|
| Linux | x64 |
| Linux | ARM64 (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
mainbranch contains only PHP code (~50KB) - Stable tags (e.g.,
1.0.0) are created on themainbranch - 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 lightweight1.0.0tag frommain - 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