D
D
Dmitry2020-09-09 13:55:09
JavaScript
Dmitry, 2020-09-09 13:55:09

Why are template engines needed in Node.js?

I'm learning node.js, I got to template engines and I can't figure out what they are for. Isn't displaying the data received from the server a task for the front? Why sculpt markup on the back and push data there?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
Gennady S, 2020-09-09
@Tim308

This is a classic approach for any server technologies in PHP, NodeJS, Python, Go, C#, Java, etc. In fact, there are only three options for a web application to work: 1) static data, when something is issued 1 to 1 , HTML, JS, media content 2) dynamic data, when they are generated by the server side and 3) client applications, when the server issues data, and the display and interface are generated on the client. There is also a hybrid approach, when pages are loaded in pieces or part of the display is formed on the client.
The first approach can be ignored, it coexists, and the second is the most common. Since most sites have dynamic content, be it a forum, news feed, store, etc., everything is generated from the database and on the server. The third approach is spreading more and more, firstly, because the load on the server is lower, the amount of transmitted data is lower, and secondly, because, as a rule, the client application is faster, but this approach has many limitations and, in general, is poorly compatible with search engines . Therefore, using templating engines as a way to generate HTML (and other things) on the server side is still the mainstream approach on the web. Try to at least bring the news feed to the main page without it.

A
Alexey Yarkov, 2020-09-09
@yarkov

For example, to render a page on the server

E
Eugene, 2020-09-09
@Nc_Soft

Just recently I used a template engine on the server to send email using templates.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question