Lesson

Question App in Nodejs, Pug, Express, Include Partials 3

Lesson Summary

In this Nodejs express tutorial we look at creating partials out of our templates. In this specific expressjs tutorial we look at separating our code into its own file. What I mean by this is, we take the code that is being repeated and inserting into a layout file ('layout.pug') and we insert our page in between the boilerplate code (the code we repeat). This includes the DOCTYPE declaration. We also separate the header and the footer into their own individual files which we likewise include in our layout file. Pug allows us to do this using a few keywords such as "include" to include our header and footer files, and extend to allow a file to be extended to our layout file.

Subscribe To Monthly Newsletter. Chance to Win Monthly Prizes

* indicates required


Share: