代码拉取完成,页面将自动刷新
同步操作将从 Michael Yang/fasty 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<!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="./test/jquery.min.js"></script>
</head>
<div style="display: none" id="text">jquery获取内容</div>
<body>
<script>
var template = "";
var data = {"title": "title test", "content": "content test..."};
var fasty = new Fasty({
share: {
name: "fasty",
sexString: function (v) {
return v === 0 ? '女' : '男';
}
}
});
template = "1.text";
console.log(fasty.render(template, data))
template = "2.{{~ var x = 100}} {{x}}";
console.log(fasty.render(template, data))
template = "3.{{\"hello world\"}}";
console.log(fasty.render(template, data))
template = '4.{{* "<div> hello world </div>"}}';
console.log(fasty.render(template, data))
template = '5.{{! "<div> hello world </div>"}}';
console.log(fasty.render(template, data))
template = '6.{{~ var array = [1,2,3]}} {{~ for(item of array)}} ---item:{{item}}-- {{~end}}';
console.log(fasty.render(template, data))
template = '7.{{~ var array = ["aaa","aa.bb",title.length]}} {{~ for(item of array)}} ---item:{{item}}-- {{~end}}';
console.log(fasty.render(template, data))
template = '8.{{~ var array = ["aaa","aa.bb",title.length]}} {{~ for(item in array)}} ---item:{{item}}-- {{~end}}';
console.log(fasty.render(template, data))
template = '9.{{~ var array = ["aaa","aa.bb",title.length]}} {{~ for(var i=0;i<array.length;i++)}} ---item:{{array[i]}}-- {{~end}}';
console.log(fasty.render(template, data))
template = '10.{{~ for(var i=0;i< Object.keys(data).length;i++)}} ---item:{{Object.keys(data)[i]}}-- {{~end}}';
console.log(fasty.render(template, data))
template = '11.test function --- {{sexString(0)}} --- {{sexString(1)}} ';
console.log(fasty.render(template, data))
template = '12.{{~ var array = ["aaa","aa.bb"]}} ' +
'{{~ for(var i=0;i<array.length;i++)}} ' +
' ---item:{{array[i]}}-- ' +
' {{~ for( x of array[i])}}' +
' {{x}}-' +
' {{~end}}' +
'{{~end}}';
console.log(fasty.render(template, data))
template = '13.{{~ if (title == content)}} ' +
'>>aaa ' +
'{{~elseif (title.length === 10)}}' +
'>>>>bbbb' +
'{{~else}}' +
'>>>cccc' +
'{{~end}}';
console.log(fasty.render(template, data))
template = '14.{{~ var array = ["aaa","aa.bb",title.length],other1="aaa,cc,dd",other2=123,other3 = title.length}}' +
' {{~ for(var i=0;i<array.length;i++)}} ' +
'---item:{{array[i]}}-- ' +
'{{~end}}'+
'{{other1}} '+
'{{other2}} '+
'{{other3}} ';
console.log(fasty.render(template, data))
template = '15.{{ $("#text").text() }} ';
console.log(fasty.render(template, data))
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。