Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "eta", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Lightweight, fast, and powerful embedded JS template engine", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -24,4 +24,9 @@ # eta (η) | ||
## Eta vs EJS | ||
## Eta vs Other Template Engines | ||
<details open> | ||
<summary> | ||
<b>Eta vs EJS</b> | ||
</summary> | ||
Eta's syntax is very similar to EJS' (most templates should work with either engine), Eta has a similar API, and Eta and EJS share the same file-handling logic. Here are the differences between Eta and EJS: | ||
@@ -37,4 +42,58 @@ | ||
- Eta exposes Typescript types and distributes a UMD build | ||
- Eta supports custom tag-type indicators. _Example: you could change `<%=` to `<%*`_ | ||
</details> | ||
<details> | ||
<summary> | ||
<b>Eta vs doT.js</b> | ||
</summary> | ||
Eta and doT.js both allow embedded JavaScript, and [both have best-in-class performance](https://cdn.statically.io/gh/eta-dev/eta/master/browser-tests/benchmark.html) when compared to other template engines (though Eta is slightly faster with HTML-escaped templates). Here are some of the differences between Eta and doT.js: | ||
- Eta allows you to control how you strip preceding and trailing whitespace after tags. | ||
- It's much simpler to set custom delimiters with Eta than doT -- you don't have to rewrite every configuration Regular Expression | ||
- Eta supports plugins | ||
- Eta supports async | ||
- Eta parses strings and multi-line comments correctly. _Example: `<%= "%>" %>` works in Eta, while the equivalent breaks in doT_ | ||
- Eta exposes Typescript types and distributes a UMD build | ||
- Eta supports runtime partials and file-handling. | ||
</details> | ||
<details> | ||
<summary> | ||
<b>Eta vs Handlebars</b> | ||
</summary> | ||
Eta and Handlebars are very different in some ways -- Eta is an embedded template engine, while Handlebars is a logic-less template engine. Here some additional differences between Eta and Handlebars: | ||
- Eta is more lightweight. Eta weighs less than **2.5KB gzipped**, while Handlebars is **~22KB gzipped** | ||
- Eta compiles and renders templates **_much_ faster than Handlebars** -- around **7x faster**. Check out these benchmarks: https://cdn.statically.io/gh/eta-dev/eta/master/browser-tests/benchmark.html | ||
- Eta allows you to set custom delimiters | ||
- Eta supports plugins | ||
- Eta exposes Typescript types and distributes a UMD build | ||
- Custom tag-type indicators. _Example: you could change `<%=` to `<%*`_ | ||
- With Eta, you don't need to register tons of helpers to do simple tasks like check if one value equals another value | ||
- Note that Eta templates run as **trusted code** -- just like any other JavaScript you write.<br><br>If you are running user-defined/created templates on your machine, server, site, etc., you probably should go with a tool built for that purpose, like Handlebars. | ||
</details> | ||
<details> | ||
<summary> | ||
<b>Eta vs ES6 Template Literals</b> | ||
</summary> | ||
Template literals are a super useful tool, especially for shortening simple string concatenation. But writing complete templates using template literals can quickly get out of hand. Here's a comparison of Eta and template literals: | ||
- Eta compiles templates into JavaScript functions that use string concatenation and have comparable performance with template literals | ||
- Eta lets you control preceding and trailing whitespace around tags | ||
- Eta gives you more flexibility with delimeters -- you could set them to `{{` and `}}`, for example, or set them to `${` and `}` to mimic template literals | ||
- Eta supports plugins | ||
- Eta supports comments with `/* ... */` syntax, just like in regular JavaScript. Template literals require you to stick a blank string after the comment: `/* ... */""`, which is much less readable | ||
- To write conditionals inside template literals, you have to use the ternary operator. Add more conditions or nested conditionals, and it quickly becomes a nightmarish mess of `? ... : ... ? ... : ...`. Writing conditionals in Eta is much simpler and more readable | ||
- Eta supports partials | ||
</details> | ||
## Why Eta? | ||
@@ -62,2 +121,3 @@ | ||
- 🔧 Precompilation | ||
- ⚡️ 0-dependency | ||
- 🔨 Partials | ||
@@ -81,7 +141,7 @@ - 🔨 Comments | ||
``` | ||
var myTemplate = "<p>My favorite kind of cake is: <%= it.favoriteCake %></p>" | ||
```javascript | ||
var myTemplate = '<p>My favorite kind of cake is: <%= it.favoriteCake %></p>' | ||
Eta.render(myTemplate, {favoriteCake: 'Chocolate!'}) | ||
// Returns: '<p>My favorite kind of cake is: Chocolate!</p> | ||
Eta.render(myTemplate, { favoriteCake: 'Chocolate!' }) | ||
// Returns: '<p>My favorite kind of cake is: Chocolate!</p>' | ||
``` | ||
@@ -91,3 +151,3 @@ | ||
``` | ||
```ejs | ||
<% if(it.somevalue === 1) { %> | ||
@@ -102,3 +162,3 @@ Display this | ||
``` | ||
```ejs | ||
<ul> | ||
@@ -113,11 +173,11 @@ <% it.users.forEach(function(user){ %> | ||
``` | ||
```ejs | ||
<%~ E.include('mypartial') %> | ||
``` | ||
``` | ||
```ejs | ||
<%~ E.includeFile('./footer') %> | ||
``` | ||
``` | ||
```ejs | ||
<%~ E.include('users', {users: it.users}) %> | ||
@@ -124,0 +184,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
226984
217