-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.html
73 lines (59 loc) · 1.75 KB
/
test.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
数组 {{ #div }} {{ /div }}
或 {{ name|age|funk }}
三目运算 {{ name ? <div></div> : <a></a> ? 'a' : 'c' }}
运算 {{ + - / * }}
枚举 {{ . }}
/\{\{\s*([#\/@\!\^]?)([a-z_A-Z]{1}[\w_\/\|\.]*)\s*\}\}/g.test();
/[a-z_A-Z]{1}[\w_]+|[\+\-\|\?\:\*]/g
/[a-z_A-Z]{1}[\w_]*?/g
{{if:div}}
/\s*[#\/]?|if|else\s?[a-z_A-Z]{1}[\w_]/g
/\s*([#\/]|(?:(if)\s+)|else)?([a-z_A-Z]{1}[\w_]*)\s*/g.exec( '{{name}}' )
<script type="javascript/tpl" id="tpl-1">
My name is {{ name|firstName }},{{@import}}
</script>
<script type="javascript/tpl" id="tpl-2">
I am {{age}} years old.
</script>
<script type="javascript/tpl" id="tpl-3">
I am love {{#instring}}{{.}}{{/instring}}
</script>
<script type="text/tpl" id="must">
My name is {{ name === undefined ? 'Olivia' : 'yanDiv' }}.{{ false ? '<div>1</div>' :'<a>2</a>' }}
</script>
<script type="text/javascript" src="./depot.core.js"></script>
<script type="text/javascript" src="./depot.extension.js"></script>
<script type="text/javascript">
var tpl = document.getElementById( 'tpl-1' ).innerHTML,
age = document.getElementById( 'tpl-2' ).innerHTML,
instring = document.getElementById( 'tpl-3' ).innerHTML,
m = document.getElementById( 'must' ).innerHTML,
sm = new String( m ),
output;
console.profile( 'render.whole' );
output = Depot.render( new String( m ),{
age: new String( age ),
firstName: 'Wei',
age: 24,
instring:
[
'football',
'programming',
'loving'
],
family:[
{ name: 'Olivia' },
{ name: 'Wei' }
]
})
console.profileEnd( 'render.whole' );
</script>
</body>
</html>