Getting Started
Quickstart
Eta is a lightweight and blazing fast embedded JS templating engine by bgub (Ben Gubler). It works inside Node, Deno, and the browser.
Install Eta
npm install etaIn the root of your project, create templates/simple.eta
Hi <%= it.name %>!Then, in your JS file:
import { Eta } from "eta"
import path from "node:path"
const eta = new Eta({ views: path.join(import.meta.dirname, "templates") })
// Render a template
const res = eta.render("./simple", { name: "Ben" })
console.log(res) // Hi Ben!Note: import.meta.dirname requires Node 20.11+.
Eta v4 is ESM-only. In browsers, import the core build:
<script type="module">
import { Eta } from "eta/core"
const eta = new Eta()
document.body.innerHTML = eta.renderString("Hi <%= it.name %>!", { name: "Ben" })
</script>