Answer the question
In order to leave comments, you need to log in
Template or what?
Now I'm using a template engine to build HTML according to json data.
When updating, the entire page, together with the header, is rendered on the server side, and when switching to other pages, data about the requested page is taken by ajax and the rendered page is inserted into the current HTML.
But what if we need to re-render a separate fragment, for example:
{
people: [
"Yehuda Katz",
"Alan Johnson",
"Charles Jolley"
]
}
<ul class="people_list">
{{#each people}}
<li>{{this}}</li>
{{/each}}
</ul>
<ul class="people_list">
<li>Yehuda Katz</li>
<li>Alan Johnson</li>
<li>Charles Jolley</li>
</ul>
{
people: [
"Katz Yehuda",
"Jolley Charles",
"Johnson Alan",
"Yehuda Katz",
"Charles Jolley"
]
}
Answer the question
In order to leave comments, you need to log in
But are there really no template engines that are capable of this?
Well, any js template will do.
be it built into some framework, or underscore, or lodash ( https://learn.javascript.ru/template-lodash) , or even a separate simple template like:
ejohn.org/blog/javascript-micro-templating
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question