1 Star 0 Fork 26

sinceity/fasty

forked from Michael Yang/fasty 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test.html 2.35 KB
一键复制 编辑 原始数据 按行查看 历史
Michael Yang 提交于 2022-05-25 19:13 . init
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>fasty</title>
<script src="./fasty.js"></script>
<script src="https://unpkg.com/art-template/lib/template-web.js"></script>
</head>
<body>
<script>
// var testhtml = "a";
// var testhtml = "{{~ for(item of array)}} xxx {{~end}}";
// var testhtml = "{{~ for(item of array)}} xxx {{~ for (newItem of item.xxx)}} xxxx {{~end}} {{~end}}";
// var testhtml = "{{~ for(item of array)}} xxx {{~ for (newItem of item1.xxx)}} xxxx {{~end}} {{~end}}";
// var testhtml = "{{~ for(var x=0;x<100;i++)}} xxx {{~end}}";
// var testhtml = "{{~ for(var x=0,a=title;x<title.length;i++)}} xxx{{a}} {{~end}}";
// var testhtml = "{{~ var aaa = \"aaa\"}}";
// var testhtml = "{{~ var aaa = \"aaa\"}} {{~ for ( x of aaa)}} {{aaa}}--{{x}}--{{end1}}--end {{~end}}";
// var testhtml = "{{~ var aaa = \"aaa\"}} {{~ for ( x of aaa)}} {{aaa}}--{{x}}--{{end1}}--end {{~end}} {{x}} {{aaa}} {{bbb}}";
// var testhtml = "{{~ var aaa = \"aaa\"}} {{~ for ( x of aaa)}} {{aaa}}--{{x}}--{{end1}}--end {{~for (var i=0;i< x.length;i++)}} {{x[i]}} {{~end}} {{~end}} {{x}} {{aaa}} {{bbb}}";
// var testhtml = "{{~ var aaa = \"aaa\"}} {{~ for ( x of aaa)}} {{aaa}}--{{x}}--{{end1}}--end {{~for (var i=0;i< x.length;i++)}} {{x[i]}} {{aaa}} {{bbb}} {{~end}} {{~end}} {{x}} {{aaa}} {{bbb}}";
// var testhtml = "{{~if (a == b)}} xxx {{~end}}";
// var testhtml = "{{~ var a = \"c\"}} {{~if (a == b)}} xxx {{~end}}";
var testhtml = "{{~ var a = \"c\",b=\"c\"}} {{~if (a == b)}} xxx {{~end}}{{title}}{{content}}";
var data = {"title": "title test", "content": "content test..."};
var fasty = new Fasty();
let time1 = new Date().getTime();
for (var i = 0; i < 10000; i++) {
fasty.render(testhtml, data);
// console.log(render)
}
console.log("time1 >>>> " + (new Date().getTime() - time1))
time1 = new Date().getTime();
for (var i = 0; i < 10000; i++) {
var testhtml = "{{set a = \"c\"}} {{set b = \"c\"}} {{if a == b}} xxx {{/if}}{{title}}{{content}}";
template.render(testhtml, data);
}
console.log("time2 >>>> " + (new Date().getTime() - time1))
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/sinceity/fasty.git
[email protected]:sinceity/fasty.git
sinceity
fasty
fasty
master

搜索帮助