Eta
Embedded JS template engine for Node, Deno, and the browser. Lighweight, fast, and pluggable. Written in TypeScript
Install / Use
/learn @bgub/EtaREADME
You're viewing the source for Eta v4
</span>Summary
Eta is a lightweight and blazing fast embedded JS templating engine that works inside Node, Deno, and the browser. It's written in TypeScript and emphasizes great performance, configurability, and small bundle size.
🎯 Built with ts-base — A TypeScript library starter template featuring Biome, Vitest, tsdown, and automated releases. Check out ts-base for a modern TypeScript project setup!
🌟 Features
- 📦 0 dependencies
- 💡 Only ~3.5 KB minzipped
- ⚡️ Written in TypeScript
- ✨ Deno support (+ Node and browser)
- 🚀 Super Fast
- 🔧 Configurable
- Plugins, custom delimiters, caching
- 🔨 Powerful
- Precompilation, partials, async
- Layout support!
- 🔥 Reliable
- Better quotes/comments support
- ex.
<%= someval + "string %>" %>compiles correctly, while it fails with doT or EJS
- ex.
- Great error reporting
- Better quotes/comments support
- ⚡️ Exports ES Modules
- 📝 Easy template syntax
Get Started
For more thorough documentation, visit https://eta.js.org
Install Eta
npm install eta
In the root of your project, create templates/simple.eta
Hi <%= it.name %>!
Then, in your JS file:
import { Eta } from "eta";
// or use https://jsr.io/@bgub/eta
const eta = new Eta({ views: path.join(__dirname, "templates") });
// Render a template
const res = eta.render("./simple", { name: "Ben" });
console.log(res); // Hi Ben!
FAQs
<details> <summary> <b>Where did Eta's name come from?</b> </summary>"Eta" means tiny in Esperanto. Plus, it can be used as an acronym for all sorts of cool phrases: "ECMAScript Template Awesomeness", "Embedded Templating Alternative", etc....
Additionally, Eta is a letter of the Greek alphabet (it stands for all sorts of cool things in various mathematical fields, including efficiency) and is three letters long (perfect for a file extension).
</details> <br />Integrations
<details> <summary> <b>Visual Studio Code</b> </summary>@shadowtime2000 created eta-vscode.
</details> <details> <summary> <b>ESLint</b> </summary>eslint-plugin-eta was created to provide an ESLint processor so you can lint your Eta templates.
</details> <details> <summary> <b>Webpack</b> </summary>Currently there is no official Webpack integration but @clshortfuse shared the loader he uses:
{
loader: 'html-loader',
options: {
preprocessor(content, loaderContext) {
return eta.render(content, {}, { filename: loaderContext.resourcePath });
},
},
}
</details>
<details>
<summary>
<b>Node-RED</b>
</summary>
To operate with Eta templates in Node-RED: @ralphwetzel/node-red-contrib-eta
<img width="150" alt="image" src="https://user-images.githubusercontent.com/16342003/160198427-2a69ff10-e8bf-4873-9d99-2929a584ccc8.png"> </details> <details> <summary> <b>Koa</b> </summary>To render Eta templates in Koa web framework: @cedx/koa-eta
</details> <details> <summary> <b>Vite</b> </summary>To use Eta templates in your Vite project: @rinoshiyo/vite-plugin-eta
</details> <br />Projects using eta
- Docusaurus v2: open-source documentation framework that uses Eta to generate a SSR build
- swagger-typescript-api: Open source typescript api codegenerator from Swagger. Uses Eta as codegenerator by templates
- html-bundler-webpack-plugin: Webpack plugin make easily to bundle HTML pages from templates, source styles and scripts
- SmartDeno: SmartDeno is an easy to setup web template using Deno & Oak
- stc: OpenAPI (Swagger) and Apifox documentation converted to api. Use eta templates to generate code.
- Add yours!
Contributors
Made with ❤️ by bgub and many wonderful contributors. Contributions of any kind are welcome!
Credits
- Async support, file handling, and error formatting were based on code from EJS, which is licensed under the Apache-2.0 license. Code was modified and refactored to some extent.
- Syntax and some parts of compilation are heavily based off EJS, Nunjucks, and doT.
Related Skills
node-connect
344.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
99.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
Writing Hookify Rules
99.2kThis skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.
review-duplication
99.9kUse this skill during code reviews to proactively investigate the codebase for duplicated functionality, reinvented wheels, or failure to reuse existing project best practices and shared utilities.
