-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsandbox.html
45 lines (42 loc) · 1.21 KB
/
sandbox.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
<!doctype html>
<html>
<head>
<script src="handlebars-v3.0.3.js"></script>
</head>
<body>
<script id="icebox_tabs" type="text/x-handlebars-template">
<ul style="list-style-type: none;">
{{#pages}}
<li><img src="{{icon}}" /> <a class="deleteable" href="{{url}}">{{title}}</a></li>
{{/pages}}
</ul>
</script>
<script>
var templates = [];
function get_template(template_name) {
if (!templates.hasOwnProperty(template_name)) {
templates[template_name] = Handlebars.compile(
document.getElementById(template_name).innerHTML
)
}
return templates[template_name]
}
window.addEventListener('message', function(event) {
var command = event.data.command;
switch(command) {
case 'render':
var template_name = event.data.template_name
var context = event.data.context
event.source.postMessage({
command: "load_html",
html: get_template(template_name)(context)
}, event.origin);
break;
}
});
document.addEventListener('DOMContentLoaded', function () {
parent.postMessage({command: 'ready'}, '*');
});
</script>
</body>
</html>