Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
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.
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!!!
EJS (Embedded JavaScript) is a simple templating language that lets you generate HTML markup with plain JavaScript. It is similar to Eta in terms of syntax and functionality, but Eta is generally faster and more lightweight.
Pug (formerly known as Jade) is a high-performance template engine heavily influenced by Haml. It is known for its clean and minimal syntax. Compared to Eta, Pug offers a more concise syntax but has a steeper learning curve.
Handlebars is a popular templating engine that provides a more logic-less approach to templates. It uses a Mustache-like syntax and is known for its simplicity and ease of use. Unlike Eta, Handlebars enforces a separation of logic and presentation.
We use the seventh letter of the Greek alphabet...
This is free and unencumbered public domain software. For more information, see http://unlicense.org/.
FAQs
Lightweight, fast, and powerful embedded JS template engine
We found that eta demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
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.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.