-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.html
127 lines (117 loc) · 2.61 KB
/
demo.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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>basic-demo</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="../src/jqoteplus.js"></script>
<style type="text/css">
h3{
background:#3d9871;color:#fff;padding:0 10px;margin:20px 0 10px;font:normal normal normal 16px/30px "Microsoft Yahei",Arial,sans-serif
}
pre{
margin: 10px 0 0 0;
padding: 10px;
border: 0;
border: 1px dotted #785;
background: #f5f5f5;
}
.result{
border: 1px dotted #3d9871;
padding: 10px;
}
</style>
</head>
<body>
<h3>$(template).jqote(data)</h3>
<code>
<pre>
var data = [{
title: 'Demo',
name: 'Len'
},{
title: 'Demo2'
}];
var html = $('#demo').jqote(data);
$('#content').html(html);
</pre>
</code>
<h3>结果</h3>
<div id="content" class="result"></div>
<h3>$.jqote(template, data[, tag])</h3>
<code>
<pre>
var data = {
title: 'Demo',
name: 'Len'
};
var html = $.jqote($('#demo').innerHTML, data);
$('#content1').html(html);
</pre>
</code>
<h3>结果</h3>
<div id="content1" class="result"></div>
<h3>$.jqotec(template[, tag])</h3>
<code>
<pre>
var lambda = $.jqotec($('#demo')[0].innerHTML);
$("content2").html(lambda.toString());
</pre>
</code>
<h3>结果</h3>
<code>
<pre id="content2">
</pre>
</code>
<h3>嵌套调用</h3>
<code>
<pre>
var template = 'jqoteplus is <%=this.name%> !<%=$("#demo").jqote(this.content);%>';
var data = {
name: 'amazing',
content: {
title: 'Demo',
name: 'Len'
}
};
var html = $.jqote(template, data);
$('#content3').html(html);
</pre>
</code>
<h3>结果</h3>
<div id="content3" class="result"></div>
<script id="demo" type="text/x-jqote-template">
<h1><%=this.title%></h1>
<div>hello, <%=this.name%></div>
</script>
<script>
var data = [{
title: 'Demo',
name: 'Len'
},{
title: 'Demo2'
}];
var html = $('#demo').jqote(data);
$('#content').html(html);
var data1 = {
title: 'Demo',
name: 'Len'
};
var html = $.jqote($('#demo')[0].innerHTML, data1);
$('#content1').html(html);
var lambda = $.jqotec($('#demo')[0].innerHTML);
$("#content2").html(lambda.toString().replace(/>/gm, '>').replace(/</gm, '<'));
// 嵌套调用
var template = 'jqoteplus is <%=this.name%> !<%=$("#demo").jqote(this.content);%>';
var data = {
name: 'amazing',
content: {
title: 'Demo',
name: 'Len'
}
};
var html = $.jqote(template, data);
$('#content3').html(html);
</script>
</body>
</html>