What is it? -- Its basically a template engine for NodeJS
What are templates? -- They're sort HTML files with direct integration with the Server so that you can build Html files with dynamic values generated in server.
Why they're used when you can build typical Frontend application? -- Well, you'd do alot in frontend app to get it running like hosting, Rest calls to server, blah blah. In case of templates, all values required inside HTML files are served directly from typical variables in server side code so that you can direclty render HTML files from server.
So why don't we use this approach instead of frontend app for everything? -- Hmm, good idea 🤔 as long as you have a simple application, thats why many admin portals follow template based because they're simple and straight forward. If your application is even medium-sized or dynamic UI components, you wouldnt be able to manage it. So, there, you'd have to choose a typical frontend app for that.
Cool, are there any other template engines? -- You'd always have an alternative for any lib in JS ecosystem. Some of them are Handlebars, Mustache, Jade and more.
Thank you for your response. Any way you could elaborate what those .ejs files inside the config folder do with the boilerplate? I mean, are they generate some .js files there based on something?
Thank you..
Actually, they have used .ejs files as templates for generating react components, routes etc dynamically. The templates(here they call it blueprints) are defined in config/blueprints folder and their name is configured in mern.json.
It follows the below syntax:
merng <blueprint-name> <name>
For example:
If you want to create a dumb/empty React Component named Posts, you'd have to enter the following command:
merng dumb-m Posts
and it generates the following:
File Generated Successfully.
Created components/Posts/Posts.js
Now if you check inside mern.json, one of the objects will have the property name equal to dumb-m referring to one of the .ejs files present inside config/blueprints.
So the point is, they're using ejs files for generating dynamic files through CLI similar to Yeoman generators available for AngularJS,
Vishwa Bhat
Technology Enthusiast
.ejsfile refers to EmbeddedJS templates.What is it? -- Its basically a template engine for NodeJS
What are templates? -- They're sort HTML files with direct integration with the Server so that you can build Html files with dynamic values generated in server.
Why they're used when you can build typical Frontend application? -- Well, you'd do alot in frontend app to get it running like hosting, Rest calls to server, blah blah. In case of templates, all values required inside HTML files are served directly from typical variables in server side code so that you can direclty render HTML files from server.
So why don't we use this approach instead of frontend app for everything? -- Hmm, good idea 🤔 as long as you have a simple application, thats why many admin portals follow template based because they're simple and straight forward. If your application is even medium-sized or dynamic UI components, you wouldnt be able to manage it. So, there, you'd have to choose a typical frontend app for that.
Cool, are there any other template engines? -- You'd always have an alternative for any lib in JS ecosystem. Some of them are Handlebars, Mustache, Jade and more.
Incase you want more info on ejs, visit
ejs.coCheers!