forked from yanhaijing/template.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.html
31 lines (27 loc) · 1.04 KB
/
config.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>config demo</title>
</head>
<body>
<script src="../template.js"></script>
<script>
template.config({sTag: '<#', eTag: '#>'});
var tpl1 = '<div><#:=name#></div>';
console.log('<##>:', template(tpl1, {name: '更改tag<##>'}));
template.config({sTag: '{{', eTag: '}}'});
var tpl1 = '<div>{{:=name}}</div>';
console.log('{{}}:', template(tpl1, {name: '更改tag{{}}'}));
template.config({sTag: '<%', eTag: '#>'});
var tpl1 = '<div><%:=name#></div>';
console.log('<%#>:', template(tpl1, {name: '不一致也可以哦,更改tag<%#>'}));
template.config({sTag: '<%', eTag: '%>', compress: true});
var tpl1 = '<div>空格会被压缩 空格 空格</div>';
console.log('compress:', template(tpl1, {}));
template.config({sTag: '<%', eTag: '%>', escape: false});
var tpl1 = '<div>默认输出不进行转义<%=html%></div>';
console.log('escape:', template(tpl1, {html: '<div>html</div>'}));
</script>
</body>
</html>