Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eta

Package Overview
Dependencies
Maintainers
2
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eta

Lightweight, fast, and powerful embedded JS template engine

  • 3.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
662K
increased by7.88%
Maintainers
2
Weekly downloads
 
Created

What is eta?

Eta is a fast, lightweight, and highly configurable embedded JavaScript template engine. It is designed to be simple and easy to use, while also being powerful enough to handle complex templating needs.

What are eta's main functionalities?

Basic Template Rendering

This feature allows you to render a basic template with embedded JavaScript expressions. The `render` function takes a template string and a data object, and returns the rendered string.

const eta = require('eta');
const template = 'Hello, <%= it.name %>!';
const data = { name: 'World' };
const result = eta.render(template, data);
console.log(result); // Output: Hello, World!

Template Caching

Eta supports template caching, which allows you to define and reuse templates by name. This can improve performance by avoiding the need to recompile templates on each render.

const eta = require('eta');
eta.templates.define('greeting', 'Hello, <%= it.name %>!');
const data = { name: 'World' };
const result = eta.render('greeting', data);
console.log(result); // Output: Hello, World!

Custom Filters

Eta allows you to define custom filters that can be used within templates to transform data. In this example, a custom filter `shout` is defined to convert a string to uppercase and add exclamation marks.

const eta = require('eta');
eta.configure({
  filters: {
    shout: (str) => str.toUpperCase() + '!!!'
  }
});
const template = 'Hello, <%= it.name | shout %>!';
const data = { name: 'World' };
const result = eta.render(template, data);
console.log(result); // Output: Hello, WORLD!!!

Other packages similar to eta

Keywords

FAQs

Package last updated on 12 Aug 2024

Did you know?

Socket

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc