Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eta-dev/eta
Embedded JS template engine for Node, Deno, and the browser. Lighweight, fast, and pluggable. Written in TypeScript
https://github.com/eta-dev/eta
deno deno-module ejs-alternative expressjs-templating-engine javascript nodejs template-engine template-engine-html typescript
Last synced: 7 days ago
JSON representation
Embedded JS template engine for Node, Deno, and the browser. Lighweight, fast, and pluggable. Written in TypeScript
- Host: GitHub
- URL: https://github.com/eta-dev/eta
- Owner: eta-dev
- License: mit
- Created: 2020-03-26T02:30:08.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-08-26T18:01:03.000Z (6 months ago)
- Last Synced: 2024-10-29T14:53:31.760Z (3 months ago)
- Topics: deno, deno-module, ejs-alternative, expressjs-templating-engine, javascript, nodejs, template-engine, template-engine-html, typescript
- Language: TypeScript
- Homepage: https://eta.js.org
- Size: 2.45 MB
- Stars: 1,419
- Watchers: 11
- Forks: 65
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
- my-awesome-list - eta - dev | 1451 | (TypeScript)
- awesome-node-esm - eta - embedded JS template engine for Node, Deno, and the browser (Packages / Template engines)
- awesome-deno - eta - Fast, lightweight, and configurable embedded template engine. (Modules / Template engine)
README
![]()
eta (Ξ·)
Documentation -
Chat -
RunKit Demo -
Playground[logo]: https://img.shields.io/badge/all_contributors-10-orange.svg "Number of contributors on All-Contributors"
[![GitHub package.json version (main)](https://img.shields.io/github/package-json/v/eta-dev/eta/main?label=current%20version)](https://www.npmjs.com/package/eta)
[![GitHub Actions Status](https://github.com/eta-dev/eta/actions/workflows/test.yml/badge.svg)](https://github.com/eta-dev/eta/actions)
[![All Contributors][logo]](#contributors-)
[![Coveralls](https://img.shields.io/coveralls/eta-dev/eta.svg?branch=main)](https://coveralls.io/github/eta-dev/eta?branch=main)
[![Donate](https://img.shields.io/badge/donate-paypal-blue.svg)](https://paypal.me/bengubler)
**You're viewing the source for Eta v3, which we just released! For v2, visit [the old branch](https://github.com/eta-dev/eta/tree/v2).**
## 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](https://eta.js.org)_
Install Eta
```bash
npm install eta
```In the root of your project, create `templates/simple.eta`
```eta
Hi <%= it.name %>!
```Then, in your JS file:
```js
import { Eta } from "eta";
// import { Eta } from "https://deno.land/x/[email protected]/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](https://github.com/shadowtime2000) created [eta-vscode](https://marketplace.visualstudio.com/items?itemName=shadowtime2000.eta-vscode).
ESLint
[eslint-plugin-eta](https://github.com/eta-dev/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](https://github.com/clshortfuse) shared the loader he uses:
```javascript
{
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](https://flows.nodered.org/node/@ralphwetzel/node-red-contrib-eta)
Koa
To render Eta templates in [Koa](https://koajs.com) web framework: [@cedx/koa-eta](https://github.com/cedx/koa-eta/wiki)
## Projects using `eta`
- [Docusaurus v2](https://v2.docusaurus.io): open-source documentation framework that uses Eta to generate a SSR build
- [swagger-typescript-api](https://github.com/acacode/swagger-typescript-api): Open source typescript api codegenerator from Swagger. Uses Eta as codegenerator by templates
- [html-bundler-webpack-plugin](https://github.com/webdiscus/html-bundler-webpack-plugin): Webpack plugin make easily to bundle HTML pages from templates, source styles and scripts
- [SmartDeno](https://github.com/guildenstern70/SmartDeno): SmartDeno is an easy to setup web template using Deno & Oak
- [stc](https://github.com/long-woo/stc): OpenAPI (Swagger) and Apifox documentation converted to api. Use eta templates to generate code.
- [Add yours!](https://github.com/eta-dev/eta/edit/master/README.md)## Contributors
Made with β€ by [@nebrelbug](https://github.com/eta-dev) and all these wonderful contributors ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
Ben Gubler
π» π¬ π β οΈ
Clite Tailor
π€ π»
Ioan CHIRIAC
π» π€
Craig Morten
π»
Rajan Tiwari
π‘
shadowtime2000
π» π€ β οΈ
Hamza Hamidi
π
Calum Knott
π€
nhaef
π»
GΓΌn
π»
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind are welcome!
## Credits
- Async support, file handling, and error formatting were based on code from [EJS](https://github.com/mde/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.