-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotTemplate_demo.js
More file actions
86 lines (78 loc) · 2 KB
/
notTemplate_demo.js
File metadata and controls
86 lines (78 loc) · 2 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
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
var dataSetSingle = {
title: 'this is title',
body: 'this is body',
new: function () {
return true
}
};
var dataSetArray = [
{
title: 'title 1',
body: 'body 1',
authorName: 'me',
new: true
},
{
title: 'title 2',
body: 'body 2',
authorName: 'me',
new: true
},
{
title: 'title 3',
body: 'body 3',
authorName: 'me',
old: function () {
return true;
}
},
{
title: 'title 4',
body: 'body 4',
authorName: 'me'
},
{
title: 'title 5',
body: 'body 5',
authorName: 'me',
tags: ['some', 'tags']
}
];
var dataForSelect = {
title: 'Select title',
name: 'select',
value: 3
};
var selectHelpers = {
options: [
{'_id': 0, 'title': 'option 0'},
{'_id': 1, 'title': 'option 1'},
{'_id': 2, 'title': 'option 2'},
{'_id': 3, 'title': 'option 3'},
{'_id': 4, 'title': 'option 4'},
{'_id': 5, 'title': 'option 5'},
{'_id': 6, 'title': 'option 6'},
{'_id': 7, 'title': 'option 7'},
{'_id': 8, 'title': 'option 8'},
]
};
var helpers = {
capitalize: function (item, index) {
return item.toUpperCase(item.title);
}
};
$(function () {
var singleElementContent = (new notTemplate({templateName: 'singleTemplate', data:dataSetSingle})).exec();
console.log(singleElementContent);
$('#singleElement').append(singleElementContent);
var selectElementContent = (new notTemplate({templateName: 'selectTemplate', data:dataForSelect, helpers: selectHelpers})).exec();
$('#selectElement').append(selectElementContent);
var manyElementsContent = (new notTemplate({
templateURL: 'templateMany.html',
data: dataSetArray
})).exec(
function (manyElementsContent) {
console.log(manyElementsContent);
$('#manyElements').append(manyElementsContent);
});
});