@molecule/api-templating-mjml 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +173 -0
  2. package/package.json +5 -4
package/README.md ADDED
@@ -0,0 +1,173 @@
1
+ <!--
2
+ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
+ Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
+ Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
+ To change this document, edit the module-level JSDoc in src/index.ts.
6
+ Generated: 2026-08-04T01:49:38.524Z
7
+ -->
8
+
9
+ # @molecule/api-templating-mjml
10
+
11
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
12
+ > It is written to be read by coding agents as much as by people, and is generated from this
13
+ > package's source — edit `src/index.ts` JSDoc, not this file.
14
+
15
+ MJML email template provider for molecule.dev.
16
+
17
+ Implements the `TemplateProvider` interface using MJML for responsive email
18
+ template rendering. Variable interpolation uses Handlebars syntax. Templates
19
+ are first interpolated with data, then compiled from MJML to responsive HTML
20
+ that works across all major email clients.
21
+
22
+ ## Quick Start
23
+
24
+ ```typescript
25
+ import { setProvider, render } from '@molecule/api-templating'
26
+ import { provider } from '@molecule/api-templating-mjml'
27
+
28
+ setProvider(provider)
29
+
30
+ const html = await render(
31
+ `
32
+ <mjml>
33
+ <mj-body>
34
+ <mj-section>
35
+ <mj-column>
36
+ <mj-text>Hello {{name}}!</mj-text>
37
+ </mj-column>
38
+ </mj-section>
39
+ </mj-body>
40
+ </mjml>
41
+ `,
42
+ { name: 'World' },
43
+ )
44
+ ```
45
+
46
+ ## Type
47
+
48
+ `provider`
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ npm install @molecule/api-templating-mjml @molecule/api-templating handlebars mjml
54
+ npm install -D @types/mjml
55
+ ```
56
+
57
+ ## API
58
+
59
+ ### Interfaces
60
+
61
+ #### `MjmlTemplateConfig`
62
+
63
+ Configuration options for the MJML template provider.
64
+
65
+ ```typescript
66
+ interface MjmlTemplateConfig {
67
+ /**
68
+ * Validation level for MJML templates.
69
+ * - `'strict'` — `render()` throws on any MJML validation error
70
+ * - `'soft'` — renders despite errors (default)
71
+ * - `'skip'` — no validation at all
72
+ *
73
+ * Defaults to `'soft'`. Note: only `render()` enforces `'strict'` —
74
+ * `renderCompiled()` never throws on MJML validation errors regardless
75
+ * of this setting.
76
+ */
77
+ validationLevel?: MjmlValidationLevel
78
+
79
+ /** Whether to minify the HTML output. Defaults to `false`. */
80
+ minify?: boolean
81
+
82
+ /** Whether to beautify the HTML output. Defaults to `false`. */
83
+ beautify?: boolean
84
+
85
+ /** File path for resolving `mj-include` relative paths. */
86
+ filePath?: string
87
+
88
+ /**
89
+ * Built-in helpers to register on creation.
90
+ * Keys are helper names, values are helper functions.
91
+ */
92
+ helpers?: Record<string, (...args: unknown[]) => string>
93
+
94
+ /**
95
+ * Built-in partials to register on creation.
96
+ * Keys are partial names, values are partial template strings.
97
+ */
98
+ partials?: Record<string, string>
99
+ }
100
+ ```
101
+
102
+ ### Types
103
+
104
+ #### `MjmlValidationLevel`
105
+
106
+ MJML validation level for template processing.
107
+
108
+ ```typescript
109
+ type MjmlValidationLevel = 'strict' | 'soft' | 'skip'
110
+ ```
111
+
112
+ ### Functions
113
+
114
+ #### `createProvider(config)`
115
+
116
+ Creates an MJML template provider.
117
+
118
+ ```typescript
119
+ function createProvider(config?: MjmlTemplateConfig): TemplateProvider
120
+ ```
121
+
122
+ - `config` — Provider configuration.
123
+
124
+ **Returns:** A `TemplateProvider` backed by MJML with Handlebars interpolation.
125
+
126
+ ### Constants
127
+
128
+ #### `provider`
129
+
130
+ The provider implementation with default configuration (soft validation).
131
+
132
+ ```typescript
133
+ const provider: TemplateProvider
134
+ ```
135
+
136
+ ## Core Interface
137
+
138
+ Implements `@molecule/api-templating` interface.
139
+
140
+ ## Bond Wiring
141
+
142
+ Setup function to register this provider with the core interface:
143
+
144
+ ```typescript
145
+ import { setProvider } from '@molecule/api-templating'
146
+ import { provider } from '@molecule/api-templating-mjml'
147
+
148
+ export function setupTemplatingMjml(): void {
149
+ setProvider(provider)
150
+ }
151
+ ```
152
+
153
+ ## Injection Notes
154
+
155
+ ### Requirements
156
+
157
+ Peer dependencies:
158
+
159
+ - `@molecule/api-templating` ^1.0.1
160
+
161
+ ### Runtime Dependencies
162
+
163
+ - `@molecule/api-templating`
164
+ - `handlebars`
165
+ - `mjml`
166
+
167
+ - Validation defaults to `'soft'` (render despite MJML errors). Set
168
+ `createProvider({ validationLevel: 'strict' })` to make `render()` throw
169
+ on invalid MJML — but note `renderCompiled()` skips validation entirely.
170
+ - `compile()` pre-compiles only the Handlebars interpolation; the MJML →
171
+ responsive-HTML conversion still runs on every `renderCompiled()` call.
172
+ - Raw (unescaped) interpolation is per-render only (`options.escape:
173
+ false` on `render()`); compiled templates always escape.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-templating-mjml",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "MJML responsive email template provider for molecule.dev",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -17,7 +17,8 @@
17
17
  }
18
18
  },
19
19
  "files": [
20
- "dist"
20
+ "dist",
21
+ "README.md"
21
22
  ],
22
23
  "keywords": [
23
24
  "molecule",
@@ -32,10 +33,10 @@
32
33
  "mjml": "5.4.0"
33
34
  },
34
35
  "peerDependencies": {
35
- "@molecule/api-templating": "^1.0.0"
36
+ "@molecule/api-templating": "^1.0.1"
36
37
  },
37
38
  "devDependencies": {
38
- "@molecule/api-templating": "1.0.0",
39
+ "@molecule/api-templating": "1.0.1",
39
40
  "@types/mjml": "5.0.0",
40
41
  "@types/node": "26.1.2",
41
42
  "typescript": "6.0.3",