js-template
Handlebars
官网:https://handlebarsjs.com/zh/
很简单,很强大,很好用,文档很详细
html
"handlebars": "^4.7.8",
vue
<script setup>
import Handlebars from 'handlebars'
let str = `<ul class="people_list">
{{#each people}}
<li>{{this}}</li>
{{/each}}
</ul>`
let template = Handlebars.compile(str);
let generateCode = template({
people: [
"Yehuda Katz",
"Alan Johnson",
"Charles Jolley",
]
});
console.log(generateCode)
</script>