1 Star 0 Fork 26

陈海龙/fasty

forked from Michael Yang/fasty 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.html 4.13 KB
一键复制 编辑 原始数据 按行查看 历史
Michael Yang 提交于 2022-06-06 16:44 . update docs
<!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>
<body>
</body>
</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;x++)}}xxx {{~end}}";
// var testhtml = "{{~ for(var x=0,a=title;x<title.length;x++)}} 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}} {{sexString?(1)}} {{a?.b?.c?().d?}}";
// var testhtml = "{{~ var a = 100}} {{~for (var i=0;i<10;i++)}} {{~ a++}} {{~end}} {{a}}";
// var testhtml = "{{~ var a = 100}} {{~ if (a ==50) }} aaa {{~ elseif(a == 100)}} bbbb{{~end}}";
// var testhtml = " {{~ if (a ==50) }} aaa {{~ elseif(a == 100)}} bbbb{{~end}}";
// var testhtml = "{{~ for (item of Object.values(title).length(aacc) )}} {{item}} {{~end}} ";
// var testhtml = "{{~ var keys = Object.keys($data),len = title.length}} {{keys}} titlelen:{{len}} ";
// var testhtml = "{{~ var keyLen = Object.keys($data).length}} {{~ if(keyLen == 1)}} 1 {{~ else if (keyLen == 2)}} 2 {{~elseif (keyLen == 3)}} 3 {{~end}} ";
// var testhtml = '<div class="modal">' +
// ' <div class="modal-dialog modal-lg">' +
// ' <div class="modal-content shadow-lg">' +
// ' <div class="modal-header">' +
// ' <h5 class="modal-title">{{title}}</h5>' +
// ' <button type="button" class="close" data-dismiss="modal" aria-label="Close" >' +
// ' <span aria-hidden="true">&times;</span>' +
// ' </button>' +
// ' </div>' +
// ' <div class="modal-body" style="word-break: break-all">' +
// ' <p>{{content}}</p>' +
// ' </div>' +
// ' <div class="modal-footer">' +
// ' <button type="button" class="btn btn-secondary" data-dismiss="modal"> 关闭 </button>' +
// ' </div>' +
// ' </div>' +
// ' </div>' +
// '</div>';
// var data = {"title": "title test", "content": "content test..."};
// var fasty = new Fasty({
// share: {
// sexString: function (v) {
// console.log("sexString>>> invoked")
// return v === 0 ? '女' : '男';
// }
// },
// safelyAccess:false,//true
// });
// var testhtml = ' {{attr}} hello {{ func1(name) }} {{* "<div> hello </div>" }} --'
var testhtml = ' {{attr}} hello {{ func1(name) }} {{! "&lt;div&gt; hello &lt;/div&gt;"}}'
var data = {name: "fasty"}
var fasty = new Fasty({
//the shared template data or functions
share: {
attr: 'text...',
func1: function (v) {
return v + " kiss~~"
},
}
});
console.log(fasty.render(testhtml, data))
console.log(document.body.innerHTML = fasty.render(testhtml, data))
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/mzsl_chenhailong/fasty.git
[email protected]:mzsl_chenhailong/fasty.git
mzsl_chenhailong
fasty
fasty
master

搜索帮助