Socket
Socket
Sign inDemoInstall

eta

Package Overview
Dependencies
0
Maintainers
2
Versions
50
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    eta

Lightweight, fast, and powerful embedded JS template engine


Version published
Weekly downloads
539K
increased by1.38%
Maintainers
2
Install size
264 kB
Created
Weekly downloads
 

Readme

Source

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

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

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 created eta-vscode.

ESLint

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 shared the loader he uses:

{
  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

image

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

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

Keywords

FAQs

Last updated on 18 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc