finds.dev← search

// the find

yanhaijing/template.js

★ 1,319 · JavaScript · MIT · updated Mar 2025

A javascript template engine, simple, easy & extras, support webpack, rspack, vite, rollup, esbuild, parcel, browserify, fis and gulp.

template.js is a JavaScript template engine using EJS-style `<% %>` syntax, with precompilation plugins for every major bundler from webpack to esbuild. It's aimed at teams doing server-rendered or build-time HTML generation who want `.tmpl` files treated as first-class assets in their build pipeline. Production users include Baidu and Meituan, so it has real-world validation.

The bundler coverage is genuinely impressive — dedicated plugins for webpack 3/4/5, rspack, vite 4/5, rollup, esbuild, parcel 1/2, browserify, fis, and gulp means you're unlikely to be blocked by your toolchain. AOT precompilation means templates compile to plain JS functions at build time with zero runtime parsing overhead. The sandbox mode and exception capture are practical additions that most minimal template engines skip. Editor plugins for VS Code, Sublime, and Atom cover syntax highlighting, which matters more than it sounds when you're staring at `.tmpl` files all day.

The template syntax is raw JavaScript execution inside `<% %>` — there's no real expression language, so you're one typo away from XSS if you use `<%= %>` instead of `<%:= %>` (the escaped variant). The distinction between those two is easy to miss and the README doesn't call out the security implications. The monorepo uses Lerna v6 with legacy bootstrap commands that are awkward in 2025 — the developer experience of working on the project itself is worse than using it. FIS3 support is preserved but FIS3 has been effectively dead for years, which raises questions about how many other plugins will eventually become abandonware. Documentation is thin beyond the basic loop example; there's an `api.md` per package but no coverage of the decorator system or data filtering API.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →