NotificationTemplates

Templates

Render notification bodies with pluggable template engines

Templates

Render chat/push/SMS bodies from templates. Each engine lives on its own subpath so you only pull in the one you use. All are edge-safe (pure JS — they run on Cloudflare Workers).

Zero-dependency string renderer

import { renderString } from "@visulima/notification/template/string";

renderString("Hi {{ user.name }}, your code is {{ code }}", { code: "123", user: { name: "Ada" } });
// "Hi Ada, your code is 123"

Supports flat and nested {{ a.b.c }} placeholders; missing values render as empty strings.

Handlebars / Liquid

handlebars and liquidjs are optional peers — install the one you need.

import { renderHandlebars } from "@visulima/notification/template/handlebars";
import { renderLiquid } from "@visulima/notification/template/liquid";

await renderHandlebars("<h1>Hello {{name}}!</h1>", { name: "John" });
await renderLiquid("Hello {{ name }}!", { name: "John" });

Using a renderer in a send

A renderer is just (template, data?) => string | Promise<string>. Render, then send:

await notify.sendToChannel("chat", { text: await renderHandlebars(template, data), to: "C123" });
Support

Contribute to our work and keep us going

Community is the heart of open source. The success of our packages wouldn't be possible without the incredible contributions of users, testers, and developers who collaborate with us every day.Want to get involved? Here are some tips on how you can make a meaningful impact on our open source projects.

Ready to help us out?

Be sure to check out the package's contribution guidelines first. They'll walk you through the process on how to properly submit an issue or pull request to our repositories.

Submit a pull request

Found something to improve? Fork the repo, make your changes, and open a PR. We review every contribution and provide feedback to help you get merged.

Good first issues

Simple issues suited for people new to open source development, and often a good place to start working on a package.
View good first issues