pug - What are the pros and cons of both Jade and EJS for Node.js templating? -


jade versus ejs, pros , cons of each , purposes each designed for?

are there any other express-compatible template engines , why?

i used jade before. nice thing jade have shorter syntax means can type faster. block in jade pretty powerful can me lot when dealing complex html code.

on other hand, hard simple stuff in jade, thing adding classes div based on simple if condition. need put

- if (isadmin)   div.admin.user - else   div.user 

jade don't differentiate between tags , variables make code confusing (at least me)

a(href='/user/' + user.id)= user.name 

jade not designer-friendly. designer friends give me html , css (they switched less still want use html), , reason if use jade need convert html jade. in jade, need use indentations, if html structure gets complicated, code horrible (especially tables). sometimes, don't know level at

table   thead     tr       td                   img     tr       td   tbody     tr       td 

recently, made switch ejs , happy far. close pure html , use same syntax of frontend template engine using (underscore template). must easier ejs. don't have conversion when receiving html templates designer friend. have replace dynamic parts variables passed expressjs. stuff make me crazy when using jade solved in ejs

<div class="<%= isadmin? 'admin': '' %> user"></div> 

and can know what ejs

<a href="/user/<%= user.id %>"><%= user.name %></a> 

if miss short syntax of jade (like me) can combine zen-coding , ejs can speed progress in general. performance, don't see differences

however, ejs not powerful jade, doesn't have blocks default (this guy implemented block feature ejs https://github.com/randometc/ejs-locals)

so, totally depend on pick whatever makes comfortable. if going use template engine frontend me, it's better if use same thing both sides

update 16 december 2013: recently, have switched ejs swig (which has similar concept of jinja2 in python world). main reason lack of block in ejs of ejs-locals. swig using plain html templates , lot of cool features template engine should have example filters , tags ejs doesn't have


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -