I want to understand what is the use of Consolidate module in NodeJS
I'll take a swing at it.
I assume you're talking about this module:https://www.npmjs.com/package/consolidatehttps://github.com/tj/consolidate.js
The short version, Consolidate.js:
There may be more aspects to it, but those are the headline features I discovered.
The author of the module does a good job documenting the use of the module, but doesn't really explain the "use-case" -- the "why" to it -- nor are there demonstrations comparing scenarios where it is used vs where it is not.To answer that, and hopefully your question, I did some digging and found these points useful.
"Express-compliant template engines such as Jade and Pug export a function named __express(filePath, options, callback), which is called by the res.render() function to render the template code.Some template engines do not follow this convention. The Consolidate.js library follows this convention by mapping all of the popular Node.js template engines, and therefore works seamlessly within Express."
Some template engines may have been developed without ExpressJS in-mind. ConsolidateJS wraps those engines and makes them ExpressJS 3.X compatible.
Also on that page:
"Note: The view engine cache does not cache the contents of the template’s output, only the underlying template itself. The view is still re-rendered with every request even when the cache is on."
Consolidate.js will cache the rendered output, too.
Hope that helps somewhat.