Comment by mg
7 days 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
Interesting, 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
[1] https://github.com/ruby/erb
The core difference here is "reactivity". You cannot build large-scale apps without state management and domdiff.
How is that related to the syntax?
Not related
Why not just embed html templates in js at this point? Why js in html?