npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@molecule/api-templating-mjml

v1.0.1

Published

MJML responsive email template provider for molecule.dev

Downloads

493

Readme

@molecule/api-templating-mjml

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

MJML email template provider for molecule.dev.

Implements the TemplateProvider interface using MJML for responsive email template rendering. Variable interpolation uses Handlebars syntax. Templates are first interpolated with data, then compiled from MJML to responsive HTML that works across all major email clients.

Quick Start

import { setProvider, render } from '@molecule/api-templating'
import { provider } from '@molecule/api-templating-mjml'

setProvider(provider)

const html = await render(
  `
  <mjml>
    <mj-body>
      <mj-section>
        <mj-column>
          <mj-text>Hello {{name}}!</mj-text>
        </mj-column>
      </mj-section>
    </mj-body>
  </mjml>
`,
  { name: 'World' },
)

Type

provider

Installation

npm install @molecule/api-templating-mjml @molecule/api-templating handlebars mjml
npm install -D @types/mjml

API

Interfaces

MjmlTemplateConfig

Configuration options for the MJML template provider.

interface MjmlTemplateConfig {
  /**
   * Validation level for MJML templates.
   * - `'strict'` — `render()` throws on any MJML validation error
   * - `'soft'` — renders despite errors (default)
   * - `'skip'` — no validation at all
   *
   * Defaults to `'soft'`. Note: only `render()` enforces `'strict'` —
   * `renderCompiled()` never throws on MJML validation errors regardless
   * of this setting.
   */
  validationLevel?: MjmlValidationLevel

  /** Whether to minify the HTML output. Defaults to `false`. */
  minify?: boolean

  /** Whether to beautify the HTML output. Defaults to `false`. */
  beautify?: boolean

  /** File path for resolving `mj-include` relative paths. */
  filePath?: string

  /**
   * Built-in helpers to register on creation.
   * Keys are helper names, values are helper functions.
   */
  helpers?: Record<string, (...args: unknown[]) => string>

  /**
   * Built-in partials to register on creation.
   * Keys are partial names, values are partial template strings.
   */
  partials?: Record<string, string>
}

Types

MjmlValidationLevel

MJML validation level for template processing.

type MjmlValidationLevel = 'strict' | 'soft' | 'skip'

Functions

createProvider(config)

Creates an MJML template provider.

function createProvider(config?: MjmlTemplateConfig): TemplateProvider
  • config — Provider configuration.

Returns: A TemplateProvider backed by MJML with Handlebars interpolation.

Constants

provider

The provider implementation with default configuration (soft validation).

const provider: TemplateProvider

Core Interface

Implements @molecule/api-templating interface.

Bond Wiring

Setup function to register this provider with the core interface:

import { setProvider } from '@molecule/api-templating'
import { provider } from '@molecule/api-templating-mjml'

export function setupTemplatingMjml(): void {
  setProvider(provider)
}

Injection Notes

Requirements

Peer dependencies:

  • @molecule/api-templating ^1.0.1

Runtime Dependencies

  • @molecule/api-templating

  • handlebars

  • mjml

  • Validation defaults to 'soft' (render despite MJML errors). Set createProvider({ validationLevel: 'strict' }) to make render() throw on invalid MJML — but note renderCompiled() skips validation entirely.

  • compile() pre-compiles only the Handlebars interpolation; the MJML → responsive-HTML conversion still runs on every renderCompiled() call.

  • Raw (unescaped) interpolation is per-render only (options.escape: false on render()); compiled templates always escape.