Search code examples
htmlnode.jstemplate-enginepug

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 template engine?


Solution

  • 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