4 ms·
Hyper syntax: <tr :for="user of users"> <td>${ user.name }</td> <td>${ user.email }</td> <td>${ user.age }</td> </tr> EJS s
by mg 1y ago
Hyper syntax:
<tr :for="user of users">
<td>${ user.name }</td>
<td>${ user.email }</td>
<td>${ user.age }</td>
</tr>
EJS syntax:
<% for (user of users) { %>
<tr>
<td><%= user.name %></td>
<td><%= user.email %></td>
<td><%= user.age %></td>
</tr>
<% } %>
I prefer EJS, because all you need to know is "<% begins JS" and "%> ends JS". Everything else is just plain HTML and JS.
The EJS website: https://ejs.co https://ejs.co
- tipiirai 1y agoThe core difference here is "reactivity". You cannot build large-scale apps without state management and domdiff.
- __jonas 1y agoInteresting, what is the origin of that syntax (EJS)? I know it from Elixir [0] and strongly dislike it there, I was under the assumption in comes from Ruby [1] since so much of Elixir is Ruby-inspired, is this JS version the original one? [0] https://hexdocs.pm/eex/EEx.html https://hexdocs.pm/eex/EEx.html [1] https://github.com/ruby/erb https://github.com/ruby/erb
- EGreg 1y agoWhy not just embed html templates in js at this point? Why js in html?