eta
Lightweight, fast, and powerful embedded JS template engine
Last updated 2 months ago by GitHub Actions .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install eta 
SYNC missed versions from official npm registry.

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
    • 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

<summary> Where did Eta's name come from? </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).


Integrations

<summary> Visual Studio Code </summary>

@shadowtime2000 created eta-vscode.

<summary> ESLint </summary>

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

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

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

image
<summary> Koa </summary>

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

<summary> Vite </summary>

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.

Current Tags

  • 4.5.1                                ...           latest (2 months ago)
  • 4.0.0-beta.1                                ...           next (7 months ago)

65 Versions

  • 4.5.1                                ...           2 months ago
  • 4.5.0                                ...           4 months ago
  • 4.4.1                                ...           5 months ago
  • 4.4.0                                ...           5 months ago
  • 4.3.1                                ...           5 months ago
  • 4.3.0                                ...           5 months ago
  • 4.2.0                                ...           5 months ago
  • 4.1.0                                ...           5 months ago
  • 4.0.1                                ...           7 months ago
  • 4.0.0                                ...           7 months ago
  • 4.0.0-beta.1                                ...           7 months ago
  • 4.0.0-alpha.2                                ...           7 months ago
  • 4.0.0-alpha.1                                ...           7 months ago
  • 3.5.0                                ...           2 years ago
  • 3.4.1                                ...           2 years ago
  • 3.4.0                                ...           2 years ago
  • 3.3.0                                ...           2 years ago
  • 3.2.0                                ...           2 years ago
  • 3.1.1                                ...           3 years ago
  • 3.1.0                                ...           3 years ago
  • 3.0.3                                ...           3 years ago
  • 3.0.2                                ...           3 years ago
  • 3.0.1                                ...           3 years ago
  • 3.0.0                                ...           3 years ago
  • 2.2.0                                ...           3 years ago
  • 2.1.2                                ...           3 years ago
  • 2.1.1                                ...           3 years ago
  • 2.1.0                                ...           3 years ago
  • 2.0.1                                ...           3 years ago
  • 2.0.0                                ...           3 years ago
  • 1.14.2                                ...           3 years ago
  • 1.14.1                                ...           3 years ago
  • 1.14.0                                ...           3 years ago
  • 1.13.0                                ...           3 years ago
  • 1.12.3                                ...           5 years ago
  • 1.12.2                                ...           5 years ago
  • 1.12.1                                ...           5 years ago
  • 1.12.0                                ...           5 years ago
  • 1.11.0                                ...           6 years ago
  • 1.10.1                                ...           6 years ago
  • 1.10.0                                ...           6 years ago
  • 1.9.0                                ...           6 years ago
  • 1.8.0                                ...           6 years ago
  • 1.7.0                                ...           6 years ago
  • 1.6.2                                ...           6 years ago
  • 1.6.1                                ...           6 years ago
  • 1.6.0                                ...           6 years ago
  • 1.5.0                                ...           6 years ago
  • 1.4.0                                ...           6 years ago
  • 1.3.0                                ...           6 years ago
  • 1.2.2                                ...           6 years ago
  • 1.2.1                                ...           6 years ago
  • 1.2.0                                ...           6 years ago
  • 1.1.1                                ...           6 years ago
  • 1.1.0                                ...           6 years ago
  • 1.0.3                                ...           6 years ago
  • 1.0.2                                ...           6 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
  • 1.0.0-beta.4                                ...           6 years ago
  • 1.0.0-beta.3                                ...           6 years ago
  • 1.0.0-beta.2                                ...           6 years ago
  • 1.0.0-beta.1                                ...           6 years ago
  • 1.0.0-beta.0                                ...           6 years ago
  • 0.0.0                                ...           13 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 33
Last Day 0
Last Week 44
Last Month 12
Dependencies (0)
None
Dev Dependencies (8)

Copyright 2013 - present © cnpmjs.org | Home |