MCPcopy Index your code
hub / github.com/bgub/eta

github.com/bgub/eta @v4.6.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v4.6.0 ↗ · + Follow
68 symbols 120 edges 25 files 1 documented · 1% 17 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

eta (η)

Documentation - Chat - Playground

GitHub package.json version (main) GitHub Actions Status Codecov Donate

You're viewing the source for Eta v4

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, blocks
  • Layout support!
  • 🔥 Reliable
  • Better quotes/comments support
    • ex. <%= someval + "string %>" %> compiles correctly, while it fails with doT or EJS
  • Great error reporting
  • ⚡️ 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

<b>Where did Eta's name come from?</b>

"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).

Integrations

<b>Visual Studio Code</b>

@shadowtime2000 created eta-vscode.

<b>ESLint</b>

eslint-plugin-eta was created to provide an ESLint processor so you can lint your Eta templates.

<b>Webpack</b>

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 });
    },
  },
}
<b>Node-RED</b>

To operate with Eta templates in Node-RED: @ralphwetzel/node-red-contrib-eta

image

<b>Koa</b>

To render Eta templates in Koa web framework: @cedx/koa-eta

<b>Vite</b>

To use Eta templates in your Vite project: @rinoshiyo/vite-plugin-eta

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.

Extension points exported contracts — how you extend this code

SimpleEtaTemplate (Interface)
(no doc)
test/render.spec.ts
Options (Interface)
(no doc)
src/config.ts
TemplateObject (Interface)
(no doc)
src/parse.ts
EtaConfig (Interface)
(no doc)
src/config.ts

Core symbols most depended-on inside this repo

loadTemplate
called by 34
src/internal.ts
trimWS
called by 13
src/utils.ts
get
called by 8
src/storage.ts
getParameterByName
called by 6
browser-tests/benchmark.js
ParseErr
called by 5
src/err.ts
define
called by 4
src/storage.ts
escapeRegExp
called by 4
src/parse.ts
reset
called by 2
src/storage.ts

Shape

Function 31
Class 18
Method 15
Interface 4

Languages

TypeScript100%

Modules by API surface

src/err.ts17 symbols
src/storage.ts8 symbols
src/internal.ts6 symbols
src/render.ts5 symbols
src/parse.ts5 symbols
browser-tests/benchmark.js5 symbols
test/plugins.spec.ts4 symbols
test/render.spec.ts3 symbols
src/utils.ts3 symbols
src/file-handling.ts3 symbols
src/index.ts2 symbols
src/core.ts2 symbols

For agents

$ claude mcp add eta \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact