artTemplate

简介
art-template 腾讯出品的一款js模板引擎。在js字符串模板插件中排第一。
插件教程:
https://www.awesomes.cn/repo/aui/arttemplate
中文API
https://aui.github.io/art-template/zh-cn/index.html
下载地址:
https://github.com/aui/art-template

实例code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <!-- 容器 -->
    <div class="Wrapp"></div>
    
    
    <!-- myTemplate模版 -->
    <script type="text/html" id="myTemplate" >
        <ul>
            <li>姓名:{{name}}</li>
            <li>年龄:{{age}}</li>
        </ul>
    </script>
   
   
   <!-- 程序 -->
    <script src="template-web.js" ></script>
    <script>
        let data = {
            name:'丁少华',
            age:20
        }

        // 将数据放入模板中
        let res = template("myTemplate", data);

        // 将模板放入页面中
        document.querySelector('.Wrapp').innerHTML = res
    </script>
</body>
</html>

原文地址:https://www.cnblogs.com/dshvv/p/7639323.html