η
Eta
Lightweight, powerful, pluggable embedded JS template engine. Written in TypeScript – use it in Node, Deno, or the browser.
A faster, more lightweight, and more configurable EJS alternative
Eta vs. EJS:
- • Eta supports Deno, out-of-the-box
- • Eta supports layouts out of the box
- • Eta allows left whitespace control (with
-
), something that doesn't work in EJS because EJS uses-
on the left side to indicate that the value shouldn't be escaped. Instead, Eta uses~
to output a raw value - • Eta gives you more flexibility with delimeters -- you could set them to
{{
and}}
, for example, while with EJS this isn't possible - • Eta adds plugin support
- • Comments in Eta use
/* ... */
which allows multiline commenting and is more consistent - • Eta doesn't break with delimiters inside strings and comments. Example:
<%= "%>" %>
works in Eta, while it breaks in EJS - • Eta exposes Typescript types and distributes a UMD build
- • Eta allows custom tag-type prefixes. Example: you could change
<%=
to<%*
- • Eta throws more informative errors. If you accidentally leave a tag, string, or multiline comment unclosed, Eta will tell you where the problem is
Users:
<ul>
<% it.users.forEach(function(user){ %>
<li><%= user %></li>
<% }) %>
</ul>
<%= await getSomeValue() %>
<% /* Eta supports multiline comments,
which is really useful */ %>
<%= "<%" %>
<%~ include("mypartial") %>
<%~ include('./navbar', { pages: [
'home',
'about',
'users'
] }) %>
<% layout("layouts/basic") %>
<p>This will be rendered into a layout</p>