Hey. I use the following code snippet to display any information on the page based on the json-array with the data:

for(let i = 0; i < data.length; i++) { $('.some-element').append(` <ul> <li>${data[i].object}</li> </ul> `); } 

In fact, the structure and hierarchy is much more complicated. An example is provided for clarity.

Can I use template engines in template strings? For example:

 $('.some-element').append(` <% _.forEach(users, function(user) { %><li><%- user %></li><% }); %> <div> <span>${data[i].some_another_data}</span> </div> `); 
  • in general, who bothers you to determine the template var tpl = "<li>[title]<li>" and then do var row = tpl.replace("[title]", item.title) . But in general, there are js-template engines, recently there was a question about the old JqueryTemplates like, which then migrated to another library - teran
  • @teran didn’t understand at all how I could use it in the template string. - JamesJGoodwin

0