finds.dev← search

// the find

tj/consolidate.js

★ 3,471 · JavaScript · updated Dec 2024

Template engine consolidation library for node.js

consolidate.js gives Express (and other Node frameworks) a single unified rendering interface across 40+ template engines. You call `cons.pug(path, locals)` instead of wiring up each engine's bespoke API. Useful if you're building a tool or framework that needs to support multiple template engines without committing to one.

The unified callback/promise API means swapping engines is a one-line change — no refactoring call sites. The `cons.requires` escape hatch lets you pre-configure engine instances (add Nunjucks filters, Handlebars helpers) before consolidate touches them, so you're not fighting the abstraction. File content caching is handled at the consolidate layer for engines that don't do it themselves, which matters in production. The engine list is genuinely broad — this covers basically every template engine that saw meaningful Node adoption.

Maintenance is effectively stalled — TJ handed it off years ago and the last meaningful activity is sporadic dependency bumps. Half the engines in the table are themselves unmaintained (dust, swig, jade, eco with a live security warning), so the breadth is somewhat illusory. There's no TypeScript support, which is a real friction point in 2024 — you get `cons[engineName]` calls with no type safety. The abstraction also means engine-specific features (Nunjucks environments, Handlebars async helpers) require undocumented options objects that you have to read the source to discover.

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 →