@eristack/email-template
Version:
{{var}} HTML/text email template render and key extraction — pair with @eristack/comms
32 lines (23 loc) • 814 B
Markdown
# Getting started
```bash
pnpm add @eristack/email-template
```
```ts
import {
extractTemplateKeys,
renderEmailTemplate,
} from "@eristack/email-template";
const template = "Hello {{name}}, your order {{orderId}} shipped.";
extractTemplateKeys(template); // ["name", "orderId"]
const html = renderEmailTemplate(
"<p>Hi {{name}}</p>",
{ name: "Ada" },
{ escapeHtml: true },
);
```
## Collaboration
Compose at the app boundary — no hard deps on `@eristack/comms` or `@eristack/person`:
1. Load person/contact data in your handler.
2. `renderEmailTemplate` with formatted strings (money amounts already formatted).
3. Pass body to `@eristack/comms` send API.
Recipe **`outbound-message-render`** lists the full pipeline (template → comms → optional PDF attachment via `@eristack/pdf-render`).