What Is A Template Engine In NodeJS.

moonchild

VIP Contributor
A Template Engine is used for rendering views on your website, so for an understanding how this works is when you're building a web app, there are three parts you have to take care of, namely.

Model
View
Controller

Model deals with how you will route your app, this means how everything links up for example when you click an about button or contact page or basically how route works.

Controller means database which is basically a schema and how you structure your data and how it is being in saved in the database, when working with nodeJS you are mostly going to use MongoDB as a database.

Views is your frontend, that is what your client see, when you put in a url in a web tab that is what you will see.

And template engine is what is used to render the view, we have different types of template engine like EJS, Pug, Eta etc, that are used.

You should also understand that template engine works like JSX in react and works like HTML, but it is more robust than HTML, with a template engine you can pass in variables and also accept them in the file.

It also accept layouts where you don't have to be repeating code in your app like Headers and Footers and also Partials
 
Top