forked from blueimp/JavaScript-Templates
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.html
More file actions
39 lines (37 loc) · 900 Bytes
/
example.html
File metadata and controls
39 lines (37 loc) · 900 Bytes
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JS Template Example</title>
</head>
<body>
<div id="content"></div>
<script src="../js/tmpl.js"></script>
<script type="text/html" id="tmpl-demo">
<h3>{%=o.title%}</h3>
<p>
Released under the <a href="{%=o.license.url%}">{%=o.license.name%}</a>.
</p>
<h4>Features</h4>
<ul>
<!--% for (var i=0; i <o.features.length; i++) { %-->
<li>{%=o.features[i]%}</li>
<!--% } %-->
</ul>
</script>
<script>
var data = {
"title" : "JavaScript Templates",
"license" : {
"name" : "MIT license",
"url" : "http://www.opensource.org/licenses/MIT"
},
"features" : [ "lightweight & fast", "powerful",
"zero dependencies" ]
};
var template = document.getElementById('tmpl-demo').innerHTML;
var result = tmpl(template, data);
document.getElementById('content').innerHTML = result;
</script>
</body>
</html>