forked from yanhaijing/template.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp.html
45 lines (42 loc) · 1 KB
/
temp.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
39
40
41
42
43
44
45
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div id="wrap"></div>
<script id="tpl" type="text/html">
<!-- html 注释 -->
<%var i = 0%>
<%var len = 3;%>
<%var a = 1; b = 3%>
a=<%:=a%>
b=<%:h=b%>
c=<%:u=c%>(空字符串)
<%=a + '1 "2"' + "2"%>
<%/*注释注释*/%>
<%for(i = 0; i < len; i++) {%>
<div>数字:<%=i%> <%=i+1%></div>
<%}%>
<div class="test" id='test'>12\t3</div>
123
<%if ('1') {
console.log("123")
}%>
</script>
<script src="template.js"></script>
<script>
// template.config({escape: false});
var tpl = template(document.getElementById('tpl').innerHTML);
var html = tpl({a: 2, b: 2});
console.log(tpl.toString());
console.log(tpl.toString().replace(/\n/g, ' '));
console.log(html);
document.getElementById('wrap').innerHTML = html;
template.config({compress: true});
var tpl = template(document.getElementById('tpl').innerHTML);
console.log(tpl({a: 2, b: 3}));
</script>
</body>
</html>