I used Jade before. The nice thing about Jade is that you have a shorter syntax which means you can type faster. The block in Jade is pretty powerful which can help me a lot when dealing with complex HTML code.
另一方面,在 Jade 中很难做一些简单的事情,比如基于一个简单的 if 条件向 DIV 中添加类。我需要把这样的东西
- if (isAdmin)
div.admin.user
- else
div.user
Jade 也没有区分标签和变量,这使得代码非常混乱(至少对我来说是这样)
a(href='/user/' + user.id)= user.name
杰德对设计师也不友好。我的设计师朋友经常给我 HTML 和 CSS (他们最近改用了 LESS,但仍然想使用 HTML) ,因此如果我使用 Jade,我需要将 HTML 转换成 Jade。同样在 Jade 中,我们需要使用缩进,因此如果您的 HTML 结构变得复杂,您的代码看起来会很糟糕(特别是表)。有时候,我甚至不知道自己处于什么水平
table
thead
tr
td
a
img
tr
td
tbody
tr
td
Recently, I made a switch to EJS and I am happy with it so far. It is very close to pure HTML and use the same syntax as that of the frontend template engine I am using (Underscore template). I must say that everything is easier with EJS. I don't have to do all the conversion when receiving HTML templates from my designer friend. All I have to do is to replace the dynamic parts with variables passed from ExpressJS. Stuff that make me crazy when using Jade are solved in EJS
So, it is totally depend on you to pick whatever makes you comfortable. But if you are going to use another template engine for the frontend like me, it's better if you use the same thing for both sides