Pug is a set of elegant and feature-rich template engines formerly known as Jade. At present, more and more companies and developers use Pug instead of HTML as the template language. So what good is it?
1. No end tag required
In HTML, almost every label needs to write an end tag, which takes time and effort to make the code more verbose, and if forgetting to write an end tag can cause unpredictable and difficult-to-locate errors. By contrast, Pug does not have an end tag, and the code is more concise and efficient.
2. Force indent
Forced indentation Some people like people don't like it, but the benefits are undeniable: It makes the style of everyone in the team unified, so that reading other people's code is no longer so scary, so that everyone has developed a good habit of indenting code, but also reduce the code formatting caused by conflicts and other issues.
3. Code Reuse and Maintenance
The Include feature in Pug allows us to no longer write the same code over and over again, such as header references and component templates. When you encounter a change, you do not have to search and modify each place one after the other, just modify one place at a time.
4. Tag notation is the same as CSS
The tags in the pug are written in the same way as the selectors in CSS, so it is more convenient to write CSS and can directly copy the tag as a selector.
These are the four greatest benefits of using Pug. The rest is waiting for you to explore.
Why you should use Pug instead of HTML