Open Drulac opened 6 years ago
Hi @Drulac The template literal not support complex condition struct.
can you give me an example of complex condition struct please :-) ?
<% if (a) { %>
balababala
<% } %>
<% for () { %>
babaljbljafa
<% } %>
and if else if, balabala
Oh it's easy to make it with template literal :-)
${(a) ? : 'blablabla' : '' }
// or for more complex
${ (()=>{
if (a) {
return 'balababala'
}
return '' //always return empty, to don't display null or undefined
})()}
using array methods like map, sort, filter, ... you can replace easily loops, or you can still use a function to do that
Template Literal is fastest, smallest and simplest template engine, because it use JS's literal template feature.
It's 55 times faster than EJS, and it also use less CPU and RAM ressources, so it may be a good idea to use it instead of EJS 😀