-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.html
More file actions
30 lines (26 loc) · 917 Bytes
/
example.html
File metadata and controls
30 lines (26 loc) · 917 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
<div id="demo-template" style="display: none;">
<img data-tpl data-tpl-src="data.image.src" data-tpl-alt="data.image.alt" />
<h1 data-tpl data-tpl-text="data.title"></h1>
<p data-tpl data-tpl-text="data.description"></p>
<a data-tpl data-tpl-href="data.href">Go</a>
</div>
<div id="target"></div>
<script src="data-templates.js"></script>
<script>
var template, target;
// Get the template and target
template = new Template(document.getElementById('demo-template'));
target = document.getElementById('target');
// Render the template inside the target
target.appendChild(
template.render({
title: 'Hello world',
image: {
src: 'http://placehold.it/300x300',
alt: 'Image of hello world.'
},
description: 'Lorem ipsum...',
href: 'http://jrnv.nl/'
})
);
</script>