-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test.html
38 lines (33 loc) · 1001 Bytes
/
Test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!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>TEST</title>
</head>
<body>
<script>
function milliFormat(num) {
return (
num &&
num.toString().replace(/\d+/, function (s) {
return s.replace(/(\d)(?=(\d{3})+$)/g, "$1,");
})
);
}
console.log(milliFormat(-1200000123123.223));
function render(template, data) {
return template.replace(/{{\s*(\w+)\s*}}/g, function (a, b) {
return data[b] || ""
})
}
var t = '<p><a href="{{url}}">{{name}}</a><span>{{greetting}}</span></p>'
console.log(render(t, {
url: 'http://www.alibaba.com',
name: 'Alibaba',
greetting: 'Welcome'
}))
</script>
</body>
</html>