forked from KanbanSolutions/jquery-tmpl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
3_if-else-tag-source.html
102 lines (87 loc) · 2.42 KB
/
3_if-else-tag-source.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="../../../jquery.tmpl.js" type="text/javascript"></script>
<link href="../../resources/demos.css" rel="stylesheet" type="text/css" />
<link href="../../resources/movielist.css" rel="stylesheet" type="text/css" />
<link href="../../resources/syntaxhighlighter.css" rel="stylesheet" type="text/css" />
<script src="../../resources/syntaxhighlighter.min.js" type="text/javascript"></script>
</head>
<body>
<a href="../../step-by-step.html">Home</a><br />
<a href="3_if-else-tag.html">Run</a>
<h3>Demo: Using {{if}} and {{else}} to render conditional sections.</h3>
<!--=================== Demo Section ===================-->
<script id="movieTemplate" type="text/x-jquery-tmpl">
<tr>
<td>${Title}</td>
<td>
{{if Languages}}
Alternative languages: <em>${Languages}</em>.
{{else Subtitles}}
Original language only... <br/>Subtitles in <em>${Subtitles}</em>.
{{else}}
Original version only, without subtitles.
{{/if}}
</td>
</tr>
</script>
<table><tbody class="header"><tr><th>Synopsis</th><th>Title</th></tr></tbody>
<tbody id="movieList"></tbody>
</table>
<script type="text/javascript">
var movies = [
{
Title: "Meet Joe Black",
Languages: "English and French",
Subtitles: "English"
},
{
Title: "Eyes Wide Shut",
Subtitles: "French and Spanish"
},
{
Title: "The Mighty"
},
{
Title: "City Hunter",
Languages: "Mandarin and Chinese"
}
];
$( "#movieTemplate" ).tmpl( movies )
.appendTo( "#movieList" );
</script>
<!--================ End of Demo Section ================-->
<h4>Data:</h4>
<pre class="brush: js;">var movies = [
{
Title: "Meet Joe Black",
Languages: "English and French",
Subtitles: "English"
},
{
Title: "Eyes Wide Shut",
Subtitles: "French and Spanish"
},
{
Title: "The Mighty"
}
];</pre>
<h4>HTML:</h4>
<pre class="brush: xml;"><script id="movieTemplate" type="text/x-jquery-tmpl">
<tr>
<td>${Title}</td>
<td>
{{if Languages}}
Alternative languages: <em>${Languages}</em>.
{{else Subtitles}}
Original language only... <br/>Subtitles in <em>${Subtitles}</em>.
{{else}}
Original version only, without subtitles.
{{/if}}
</td>
</tr>
</script></pre>
</body>
</html>