I have accumulated some information about possible methods of templating, but I still could not find anything where it would be clearly explained what and in what cases it is better to use. So I decided to write out some pros and cons of each type as I understand them, and discuss them with you ... because I need to discuss this with someone :)
1. Client templateization with json rest api
We get data from the database => we transfer them to the client in json / xml => we parse the data on the client, creating objects by client models => we add each obtained model to the DOM.
pros:
- the user is waiting only for the data he needs
- in the process of loading data, we can show a beautiful preloader
minuses:
- duplicate models
- once again straining the client browser with templating
2. Also rest api, only template making, as a whole, server
We get the data out of the database => create the html code from them => give it to the client html => on the client, just shove the resulting html into the DOM without thinking.
This method seems to me the most practical, but for some reason practically no one writes about it. Am I just reading something wrong, or are there any serious flaws that I just don’t see?
pros:
- first two of paragraph above
- do not duplicate models
minuses:
- it looks like there are none
3. Classic server templateization ... only server
Selecting data from the database => on the server, we do this whole thing in html, but not a piece of the page, but the whole page entirely => reload the entire page to the client.
pros:
- do not duplicate models
minuses:
- we redraw everything that the user already had and all the resulting lack of preloaders, a blank white page, and so on
Questions
- What other variations are there?
- Who uses what in their projects (personal, workers, how do large companies ...)?
- Why?
- What are the pros and cons I missed / misunderstood?
- In which case what is better to use?
angularjs, ember, knokout
? At the expense of 2 ways - minus: it is difficult to make reused components. - Stepan Kasyanenko