-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
55 lines (54 loc) · 1.88 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel='stylesheet' href='https://cdn.jsdelivr.net/gh/kognise/water.css@latest/dist/light.min.css'>
<title>Elche</title>
</head>
<body>
<div id="app"></div>
<script src="dist/elch.js"></script>
<script>
// Test include.
const includeMe = new Elch({
name: 'include-me',
state: { count: 0 },
logic: { incrementCount(){ this.count += 2; } },
view: () => /*html*/`
<div class="include-me">
<button do-event="click:incrementCount">Increment inner</button>
<p>I am another template. My count: {{count}}</p>
</div>`
});
// Test Template
const myTemplate = new Elch({
name: 'my-template',
state: { count: 0 },
logic: { incrementCount(){ this.count += 1; } },
using: [includeMe],
view: () => /*html*/`
<div class="bob">
<h1>Just a demo!</h1>
<include-me>Hi</include-me>
<do if="this.name.length > 0">
<p id="idval" class="classval">Total updates since creation: {{count}}!</p>
</do>
<do if="this.state.count > 2">
<p>count greater than 2</p>
</do>
<button do-event="click:incrementCount">Performance test</button>
<do for="let i=0; i<this.state.count; ++i">
<do for="let j=0; j<this.state.count; ++j">
<p>{{$i}} * {{$j}} = {{ $i * $j }}</p>
</do>
</do>
<input type="text" value="${window.performance.now().toFixed(2)}" readonly>
</div>`
});
console.log('Template created: ', myTemplate);
myTemplate.mountTo(document.getElementById('app'));
</script>
</body>
</html>