eta
TypeScript icon, indicating that this package has built-in type declarations

3.5.0 • Public • Published

eta (η)

Documentation - Chat - RunKit Demo - Playground

GitHub package.json version (main) GitHub Actions Status All Contributors Coveralls Donate

You're viewing the source for Eta v3, which we just released! For v2, visit the old branch.

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.

🌟 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
    • Great error reporting
  • ⚡️ Exports ES Modules as well as UMD
  • 📝 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";
// import { Eta } from "https://deno.land/x/eta@v3.1.0/src/index.ts";

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

Where did Eta's name come from?

"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

Visual Studio Code

@shadowtime2000 created eta-vscode.

ESLint

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

Webpack

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

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

image
Koa

To render Eta templates in Koa web framework: @cedx/koa-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 @nebrelbug and all these wonderful contributors (emoji key):

Ben Gubler
Ben Gubler

💻 💬 📖 ⚠️
Clite Tailor
Clite Tailor

🤔 💻
Ioan CHIRIAC
Ioan CHIRIAC

💻 🤔
Craig Morten
Craig Morten

💻
Rajan Tiwari
Rajan Tiwari

💡
shadowtime2000
shadowtime2000

💻 🤔 ⚠️
Hamza Hamidi
Hamza Hamidi

📖
Calum Knott
Calum Knott

🤔
nhaef
nhaef

💻
Gün
Gün

💻

This project follows the all-contributors specification. 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.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
3.5.0139,062latest

Version History

VersionDownloads (Last 7 Days)Published
3.5.0139,062
3.4.1487
3.4.019,463
3.3.0423
3.2.06,974
3.1.18,025
3.1.01,051
3.0.3291
3.0.20
3.0.10
3.0.01
2.2.0458,159
2.1.2101
2.1.1922
2.1.00
2.0.110,238
2.0.011,126
1.14.229,402
1.14.1167
1.14.02
1.13.0229
1.12.332,978
1.12.2178
1.12.14,287
1.12.02
1.11.0111
1.10.11
1.10.00
1.9.02
1.8.00
1.7.01
1.6.21
1.6.10
1.6.00
1.5.00
1.4.01
1.3.02
1.2.2301
1.2.11
1.2.00
1.1.1166
1.1.00
1.0.30
1.0.20
1.0.10
1.0.01
1.0.0-beta.41
1.0.0-beta.30
1.0.0-beta.20
1.0.0-beta.10
1.0.0-beta.00
0.0.05

Package Sidebar

Install

npm i eta

Homepage

eta.js.org

Weekly Downloads

724,162

Version

3.5.0

License

MIT

Unpacked Size

272 kB

Total Files

35

Last publish

Collaborators

  • nebrelbug
  • shadowtime2000