I publish a few articles and tutorials each week, please consider entering your email here if you’d like to be added to my once-weekly email list. pug file looks like, and why a template engine is important in web development. Hopefully, you can now understand what Pug.js is, what a.
#PUG TEMPLATE INJECTION FULL#
You can view the weather website full code (using Pug) on Github. With Pug, you can’t copy HTML from anywhere, you have to convert everything to Pug before you can use it.The slightest mistake in your formatting/indenting/spacing means big problems for your code. Most importantly, we can write JavaScript that actually (almost/kind of) looks like JavaScript within our pug files.There are even shorthands for classes (.) and IDs (#) Pug makes use of indentation to determine the nesting of tags. This greatly improves code-readability and streamlines projects with multiple developers. When you write with Pug, you write code that looks like paragraphs.Switching from EJS to Pug brought our code down from 27 lines to just 17!.ejs file looked like in my last tutorial: Set up your view engine: app.set(‘view engine’, ‘pug’).