eta-dev / eta

Embedded JS template engine for Node, Deno, and the browser. Lighweight, fast, and pluggable. Written in TypeScript
https://eta.js.org
MIT License
1.42k stars 65 forks source link
deno deno-module ejs-alternative expressjs-templating-engine javascript nodejs template-engine template-engine-html typescript

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

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](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) image
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

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