What are the alternatives to js loop stitching strings?

such as product list

<li>
    <img src="../../tu.png"/>
    <div>:12</div>
</li>

when I used to write in jquery, I stitched the li into a string, then looped through an array of pictures, and looped together the li string. Finally, append the looped li string into the ul of the page.
is there any better way to replace this kind of circular stitching string? once the structure in li becomes complex, circular stitching string will be very painful. I think h5 has a new template tag, but when I looped through the image array append template, I found that in the end, only one li could be append.

May.29,2021

choose a js template engine with complex structure
for example: https://aui.github.io/art-tem.


these operations are stitched together using templates.

recommend juicer template engine produced by Ali.

https://github.com/PaulGuo/Ju.


if you are using es6, consider using template strings. If it is not es6, consider using a template engine.

Menu