I am having trouble understanding the use of app.engine in my project as there are two lines of code
app.engine('ejs',ejsMate); app.set('view engine','ejs') I tried to google it's use and viewed a similar question in here
The thing I am trying to ask is why .engine is used and why I even have to import ejs-mate in my project, as I noticed that even when I comment the first line the code renders all the views without any errors.
My view files contain only files with .ejs extension but those files have html along with ejs. So what is the use of .engine in node.js.
In the similar question also, the user @Trialcoder asked about html and ejs's use together and the answer said it was to use both html and ejs together but it can be done just by the second line as I have noticed.
When I tried commenting the first line like this
// app.engine('ejs',ejsMate); app.set('view engine','ejs'); I thought the routes that sent res.render() replies would give some error that the view engine is not defined, but everything ran like before.
Note: I am a newbie to the express framework and node.js. So, answers with in-depth details would be great.