Why do we use server templates for Node?

For example, I see Node.js in which a lot of people mention the use of jade or swig. I am creating a Node.js application that will use a RESTful interface to communicate with a client. I want to be able to send and receive updates. A lot of the tutorials I've seen or the apps I've seen on the web use jade or some other kind of pattern engine.

What is the advantage of using the template engine on the server, and not just serving the regular html / javascript buffer and providing the client with specific pages based on what information is sent to the server from the server? How does the server extension mechanism improve the use of the RESTful interface? edit: is there any advantage or is it just personal preference?

If this is profitable in some way, I will take the time to study it now, before I get too far in my project, and I don’t want me to find out earlier: -D

Here is an example of using Jade-lang.

+4
source share
1 answer

Markup languages ​​like SGML are hard to read for both computers and programmers. Template engines typically speed up programming using smaller tokens and syntax. In addition, if you use the preprocessor required for templates, you can usually add variables and logic.

The disadvantage is that it takes cycles to display the template. This is usually not a problem, since most projects are hindered by time to market, rather than a lack of processing efficiency.

I use Jade for most of my projects because it is very easy to switch from HTML to Jade as well as intuitively. I had no difficulty with the learning curve going from HTML to Jade.

0
source

Source: https://habr.com/ru/post/1494627/


All Articles