-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.html
More file actions
106 lines (91 loc) · 2.17 KB
/
test.html
File metadata and controls
106 lines (91 loc) · 2.17 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<html>
<head><!--STATUS OK-->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Test</title>
<style type="text/css">
body{padding:5px;margin:0;font-size:12px;font-family:Consolas}
</style>
</head>
<body>
<script src="template.js"></script>
<script id="1" type="template">
<%:u=name %>
<%
var s = 'Enter\"\n\"';
print(company);
%>
<%=s %>
<%# This is comment %>
<% /*This is comment*/ %>
</script>
<script id="2" type="template">
<%# test custom function %>
<%:u=name %>
<%
var str = "HelloWorld! ";
output(company);
%>
<%:u=str %>
</script>
<script id="3" type="template">
<%
if (name === 'PengXing') {
print(name);
} else {
print("unknown name");
}
%>
</script>
<script id="4" type="template">
<%:h=name %>
<%
var s = "<script>var s = 'HelloWorld!';<\/script>";
%>
<%:h=s %>
</script>
<script id="5" type="template">
<%
var s = "<script>var s = 'HelloWorld!';<\/script>";
encodeHTMLAndPrint(s);
%>
</script>
<script>
var Timer = function(){
this.start = function(){
this.st = new Date();
};
this.end = function(){
this.et = new Date();
};
this.log = function(){
return this.et - this.st;
};
};
</script>
<script id="test">
var tplIds = ['1', '2', '3', '4', '5'];
var html = [];
var timer = new Timer();
for(var i = 0, l = tplIds.length; i < l; i++){
var id = tplIds[i];
var template = document.getElementById(id).innerHTML;
timer.start();
html.push(tpl(template, {
name: 'PengXing',
company: 'baidu'
}, {
fns : {
output : 'function(str){__s+=str}',
encodeHTMLAndPrint : 'function(s){print(encodeHTML(s))}'
}
}));
timer.end();
html.push("tpl: " + timer.log());
var div = document.createElement('div');
div.innerHTML = html.join('<br/>');
}
document.body.appendChild(div);
</script>
</body>
</html>