eta v3.5.0
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
- ex.
- Great error reporting
- Better quotes/comments support
- β‘οΈ 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
"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
@shadowtime2000 created eta-vscode.
eslint-plugin-eta was created to provide an ESLint processor so you can lint your Eta templates.
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 });
},
},
}
To operate with Eta templates in Node-RED: @ralphwetzel/node-red-contrib-eta
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):
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.
4 months ago
3 months ago
8 months ago
8 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
12 years ago