The scope of application of the backend-template engines?

As I understand it, the templating engines (mustache, ejs, twig, etc.) used for dynamic page generation, data transfer from the backend to the frontend (for example, if the user profile is loaded, the page arrangerede from his data).

But what it has meaning, if all the data you can just pull from the frontend via the api of the backend?
What are the advantages of the first approach and the second?
Or maybe they can/need on one site to combine? In this case, for some tasks better suited to the first approach or the second?
April 18th 20 at 13:15
2 answers
April 18th 20 at 13:17
1. You can combine
2. Can not be combined.
3. Advantages recoil buck all ready, no waiting or rape yourself in the foot, adjusting the PreRender, for example.
4. Security: all that lies in front sees anyone, all is in the logic of the templating engine or buck sees one, even when he attenderen.
5. Not relevant to SPA for REST API (curve a little soul).
Etc. flows in and out effects.

Compare back-up engines on the basis of their actions with the front, IMHO, is not the healthiest idea, because they work differently.
Thank you. I compare them not work, and on the application. In fact, as I understand it, they are often used for the same task.

So, if we are not talking about the SPA, it's just a matter of taste/accepted at team practices? - gail commented on April 18th 20 at 13:20
@Valentina_Dickinson, no, the decision is made on the basis of the problem.

In the case of a SPA it is generally assumed the REST API (which does not necessarily), hence is a stack in the form of a JS framework, in which there is simply no back-and, by definition, and there are templates that are built on the basis of responses from the API.

And yet again I will say — stack approach and everything else is decided first and foremost tasks facing the developers. Not a fashion decision (although often it is), namely the task. Well, the prism of skills and knowledge. Factors in fact many. - kelly63 commented on April 18th 20 at 13:23
@DeeDee.Boyer, thank you. That's why I asked this question to understand when a task has to approach, and when to another. So the next time I have not encountered the question "what should I use?"

By the way, except in the case of SPA, the backend will not be the server on which revolves the API and all business logic? - gail commented on April 18th 20 at 13:26
@Valentina_Dickinson, all right, the business logic turns on the buck, the exchange takes place via http-Protocol, SPA simply shows that it's in response to the request.

Itself SPA app can rotate anywhere, though you have to the local computer, the main thing is to be able to send requests and receive responses, i.e. most likely the Internet connection.

That's why I asked this question

Nuances, perhaps a lot actually. In principle, I can say that for anything functional scheme is used where the backing is independent and interacts with the outside world via the web api (If that API is not just a query response type of json on the web), and face, she's an app, it often only SPA around somewhere on the sidelines. Level applications for devices. This allows us to provide the same approach to the appeals to the core logic with a wild variety of the final product.

However, this need not always + I again focuses attention on security. Not always, for example for lindosa don't need it. For a site that does not use calculations, but merely gives the content too. Blozhik some on the knee — there is generally optimal to use a thread of Jekyll, which is not included in the discussion and so on.

And in terms of security, there is also simple, often sewn into the SPA logic user and administrator. All that separates the user from manipulating the server, the encrypted token, which the browser stores when you log into the system. Regardless of whether he came or not, all logic is just thrown out in the form of JS-nick, who come in, see what messages the server can be and go try to demolish something.

Of course, there are approaches to correct, but due to the fact that is so fashionable, safety an afterthought. Not the most obvious factor.

It should be noted that if you make a website which is loaded and here it is the whole — the whole dynamic you do not need, better to just dump everything in the templating engine. Well, maybe somewhere asynchronous components to cram.

In the SIM are done, success in the field. - kelly63 commented on April 18th 20 at 13:29
April 18th 20 at 13:19
But what it has meaning, if all the data you can just pull from the frontend via the api of the backend?
Legacy projects and the conservatives.
Before the frontend on the backend rendering.

Combining makes no sense: it is now easier to make a PreRender technologies front-end.
Got it, thanks.
That is, in your words, approach with a server render obsolete and now rarely used? I just thought that this is not so, because in the lessons node.js and the documentation quite extensively renderers. And, apparently, they are also often used. So I have a question, which approach in which situation is better or is it just a matter of taste. - gail commented on April 18th 20 at 13:22
@Valentina_Dickinson, outdated, but not uncommon... In large projects did not see the render server, except admins. But I'm in a big work small projects with many template engines - Frieda.Kub commented on April 18th 20 at 13:25
@Valentina_Dickinson, the problem with this render is that to work with it need a little bit, but fullstack developers.
It is a monolith, where frontend and backend are blind in one app.
This approach is very old, earlier the alternatives and it wasn't. It is much easier for beginners. Much easier to do something on the knee with this approach. Be much simpler infrastructure.

And the separation of backend and frontend using REST or alternatives allows you to share responsibility and tasks. Easier and cheaper long-term support of the project. Be much simpler to develop a mobile app "all ready."

They are for different tasks. We must proceed from the tasks and to evaluate the pros and cons of the task. - ward commented on April 18th 20 at 13:28
@krystal41, now I understand. Thank you! - gail commented on April 18th 20 at 13:31
@May_Gusikowski, okay, so template engines is, in most cases, the tool is more for small projects to quickly and easily sculpt a small project. Thank you! - gail commented on April 18th 20 at 13:34
@Valentina_Dickinson, not only. He's much smaller (in the tens if not hundreds of times) the skill requirements of the front-end requires. So bekendt can make a website without a separate frontengine, having only a basic frontend skills (html, css). - ward commented on April 18th 20 at 13:37
@krystal41, well, reasonable. Take a note of that. - gail commented on April 18th 20 at 13:40

Find more questions by tags Template buildersBackend