开发者

What are the pros and cons of using a template engine like Jade?

I'm looking into developing a web app with Node.js. I'm coming from a PHP background where I didn't use a template engine (besides PHP itself) and I have always just written straight HTML. So, why should I or should I not use Jade or some other tem开发者_如何学JAVAplate engine?


Pros:

  • Encourages good code organization (data generation is separate from presentation code)
  • Output generation is more expressive (template syntax doesn't require a sea of string concatenation)
  • Better productivity (common problems such as output encoding, iterating, conditionals, etc. have been handled)
  • Generally requires less code overall (jade in particular has a very terse syntax)

Cons:

  • Some performance overhead
  • Yet another thing to learn


About JADE or any other template language that differ a lot from HTML:

First of all it is more time consuming to debug the produced HTML. You see HTML in the browser and you need to parse it back to JADE (in your brain) to compare with your editor content. This is very inconvenient and makes debugging harder then it should be.

Of course it may not be a problem if you are the only programmer who works on the code. It may seem so easy to match the html lines with JADE lines if you are the one who wrote them.

It is a problem when working in teams.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜