drupal/mjml_render_bin
最新稳定版本:1.0.0
Composer 安装命令:
composer require drupal/mjml_render_bin
包简介
Standalone MJML to HTML renderer with pre-built binaries. No Node.js required at runtime.
README 文档
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
统计信息
- 总下载量: 28
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2026-04-27