K
K
Klein Maximus2014-08-12 21:05:32
Node.js
Klein Maximus, 2014-08-12 21:05:32

How to call a route from a template in Express (Node.js)?

I'm starting to learn Node.js and I have this question...
Let's say a template engine (for example, ect) already renders the main page of the site / according to the template. The template is extended (extend) by another template (essentially this is a layout). There is a block in the layout that also needs to be displayed (for example, a list of news). This list of news can also be obtained via the /news/ route.
How can I call the route responsible for /news/ from a template?
I hope I wrote clearly.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Krasnodemsky, 2014-08-13
@Prognosticator

no, it's not clear :) attach the code or a picture of what should be in the end.

K
Klein Maximus, 2014-08-13
@kleinmaximus

Let's take twig as an example.
There is a '/' route. It renders the main page according to the index. The template itself is extended by the layout template via extends.
There is also a '/news/' route. It renders a page with a list of news news, but this template is not expanded, but is displayed as is.
So, I want to go directly from the layout template to the /news/ route so that it returns the rendered list of news that will be inserted into the layout.
How can I do that?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question