
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
@templatical/renderer
Advanced tools
JSON → MJML renderer for Templatical email templates. Runs in the browser or on Node.
Converts Templatical's JSON template format into MJML, which you then compile to HTML using any MJML library. Pure functions, zero runtime dependencies aside from @templatical/types.
Use this on your backend to render templates server-side before sending email — or in the browser to preview before save.
npm install @templatical/renderer mjml
import { renderToMjml } from '@templatical/renderer';
import type { TemplateContent } from '@templatical/types';
const content: TemplateContent = JSON.parse(stored);
const mjml = await renderToMjml(content);
renderToMjml is async — it returns Promise<string>. Custom blocks may need async work to resolve, so the call always returns a promise even when content has none.
import { renderToMjml } from '@templatical/renderer';
import mjml2html from 'mjml';
const mjml = await renderToMjml(content);
const { html } = mjml2html(mjml);
// Send via Postmark, Resend, SES, Mailgun, anything
await mailer.send({ to, subject, html });
const mjml = await renderToMjml(content, {
customFonts: [
{ name: 'Geist', url: 'https://fonts.googleapis.com/...' },
],
defaultFallbackFont: 'Arial, sans-serif',
allowHtmlBlocks: true,
});
The renderer doesn't know how to render custom blocks on its own — you supply a callback. Editor consumers wire this automatically through editor.toMjml(). Headless callers provide their own resolver:
const mjml = await renderToMjml(content, {
async renderCustomBlock(block) {
// e.g. run the same liquid template the editor uses, against block.fieldValues
return await myLiquidEngine.render(block.customType, block.fieldValues);
},
});
If you don't pass renderCustomBlock, the renderer falls back to the block's renderedHtml field (if any) and otherwise omits the block from output.
renderToMjml(content, options?): Promise<string> — render TemplateContent to an MJML string. Pair with the mjml package to compile to final HTML.Options:
customFonts — CustomFont[] declarations rendered into <mj-attributes>defaultFallbackFont — fallback when a block doesn't specify a fontallowHtmlBlocks — pass false to strip HTML blocks before render (e.g. for untrusted content)renderCustomBlock — (block: CustomBlock) => Promise<string> — resolves custom blocks to HTMLFull reference at docs.templatical.com.
MIT
FAQs
Render Templatical email templates to MJML
The npm package @templatical/renderer receives a total of 2,444 weekly downloads. As such, @templatical/renderer popularity was classified as popular.
We found that @templatical/renderer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.