I Built a Template Engine Library
I created an HTML template engine library for TypeScript and JavaScript. It's called minimal-te (minimal template engine).
Background
I wanted to try out Cloudflare, so I decided to build a simple web application with Hono and deploy it to Workers.
The question was: how do I embed data into HTML? I couldn't find anything that fit well.
Hono recommends using jsx/tsx, but I wasn't familiar with it (yes, I know I should just learn it). On the other hand, EJS — a popular existing template engine — uses Node.js built-in APIs like fs internally, which means it doesn't run on Workers.
So I thought: why not just build one?
Features
- Zero dependencies — No external libraries required. Install and use immediately
- Edge Runtime compatible — No use of Node.js built-ins like
fs, so it runs on Cloudflare Workers and other Edge Runtimes - Simple API — Just one function to learn
Who This Is For
If you've been using Express with EJS for server-side rendering and are now migrating to Hono + Cloudflare Workers, you've probably hit the same wall.
Cloudflare Workers runs on V8-based Edge Runtime — not Node.js. That means Node.js APIs are unavailable. EJS calls fs.readFileSync internally, which throws a runtime error on Workers. Switching to jsx/tsx also comes with a learning curve.
minimal-te was built to solve exactly this problem. It uses an EJS-like placeholder syntax that feels familiar, while being fully compatible with Edge environments.
Usage
The library exports a single function minimalTE. Pass an HTML string and an array of objects as arguments.
import { minimalTE } from 'minimal-te';
const html = '<p><% name %></p>';
const result = minimalTE(html, [{ name: 'Hello!' }]);
// <p>Hello!</p>
In the HTML template, use <% %> or <%table %> as placeholders. Values are pulled from the object array passed as the second argument.
Available on npm
I plan to keep growing this library, so please check it out ☝
https://www.npmjs.com/package/minimal-te
A more detailed breakdown of the features will be posted separately.