W
W
web_dev2014-12-06 22:37:23
JavaScript
web_dev, 2014-12-06 22:37:23

Difference between template engines(velocity, freemaker) and jQuery?

Hello.
I have a question like this.
And what is better or worse than template engines (velocity, freemaker and others) than, for example, just jQuery?
Let's take the most common example.
In the case of the template engine.

@RequestMapping("/")
    public String list(ModelMap model) {
        model.put("feeds", feedService.getFeeds());
        return "list";
    }

We hammer in the model, send the name of the template.
But after all with the same success we do the following.
@RequestMapping("/")
    public String list(ModelMap model) {
        return new ReturnObject();
    }

After sending a real object in which there will be all the necessary data, the client will receive json, jQuery will calmly process the object.
Thus, we will completely separate frontend and bbackend.
Or I do not understand something, where are the pros and cons of each?
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Ozeransky, 2014-12-06
@KREGI

neither worse nor better, it’s just that different approaches are possible and this is solved at the design level based on the task, someone uses template engines, someone doesn’t, and besides, what you came to (to separate the frontend and backend) has long been invented, for example in the MVC pattern.
jQuery is a JS library that makes it easy to work with the DOM, with AJAX. The template engine is something else, its purpose is to separate the presentation layer and the business layer in a web application. JSON, you can parse not only JQuery, but any JS library capable of it (if you need to do it on the client). It seems to me that you need to understand the concepts, otherwise you are confusing cold with sweet.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question