I use the EJS template engine in my Node.js and Express application, and so far have used its functionality and rendering, and so far there have been no problems.
However, although I have always used the syntax res.render(filename, options, callback)in my server program to render the contents of the file, I wonder what the difference is between res.render()and ejs.render().
Both methods seem to take the render file name as the first argument and Object to insert into the file as the second argument (e.g. {title: "title here"}). res.render()can take a callback function as the third (optional) argument, and I used it whenever I want to use nested rendering, but from the documentation of the EJS Github repository it may not be able to accept the callback, again, at least the documentation in the repository Github does not accept the argument (although in any case its argument will be optional).
So, I wonder what the difference is between res.render()and ejs.render(). If only it res.render()can take a third argument, what is the point of use ejs.render()? Or is there anything that ejs.render()can use that res.render()cannot? In general, what function should I use in my application?
I am writing app.set('view engine', 'ejs');to use EJS in my application for your information.
source
share