This repository was archived by the owner on Aug 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathexample.html
More file actions
46 lines (38 loc) · 1.24 KB
/
example.html
File metadata and controls
46 lines (38 loc) · 1.24 KB
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
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>tmpljs basic example</title>
</head>
<body>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="tmpl.js"></script>
<script>
$(function(){
var template = [
"div",
" .hello This div has a class of 'hello'",
" getTag(p).world {myvar} yeah",
" form#mainForm",
" input$theinput Default text",
"div[data-main=cat in the hat]",
" p$wrapper",
" span a {getAnAnimal} is an animal, ",
" span another animal is a {x.anotherAnimal}"
],
data = {
myvar: "oh",
getTag: function(tagName){ return document.createElement(tagName);},
getAnAnimal: function(){ return this.animal; },
animal: "cat",
x: {
anotherAnimal: "dog"
}
},
compiled = $.tmpl( template, data );
console.log( compiled );
$("body").append( compiled );
compiled.c.theinput.focus();
});
</script>
</body>
</html>