Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use template-literal instead of EJS #37

Open
Drulac opened this issue Jan 7, 2018 · 4 comments
Open

Use template-literal instead of EJS #37

Drulac opened this issue Jan 7, 2018 · 4 comments

Comments

@Drulac
Copy link

Drulac commented Jan 7, 2018

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 😀

@JacksonTian
Copy link
Member

Hi @Drulac The template literal not support complex condition struct.

@Drulac
Copy link
Author

Drulac commented Jan 8, 2018

can you give me an example of complex condition struct please :-) ?

@JacksonTian
Copy link
Member

<% if (a) { %>
balababala
<% } %>

<% for () { %>
babaljbljafa
<% } %>

and if else if, balabala

@Drulac
Copy link
Author

Drulac commented Jan 8, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants