-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.html
51 lines (47 loc) · 1.38 KB
/
example.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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>example</title>
<script src="./index.js"></script>
</head>
<body class="">
<div id="ashjs"></div>
<script type="text/javascript">
const routes = {
"/": () => `
-div(id="wrapper")
--div(id="count")
---"Current count: ${store.count}"
--button(onclick='increaseCountBy("1")')
---"Increase count"
--button(onclick='increaseCountBy("2")')
---"Increase count by two"
--button(onclick="goToCountPage")
---"go to count page"
`,
"/count/:count": ({ urlInformation }) => `
-div(id="count")
--"Showing count ${urlInformation.urlParams.count}"
`,
};
const store = { count: 0 };
const events = {
increaseCountBy: (rawData, render) => {
const data = JSON.parse(rawData);
const byValue = parseInt(data);
if (isNaN(byValue)) {
return;
}
store.count += byValue;
render("count");
},
goToCountPage: (_data, render, emit) => {
emit("go", `/count/${store.count}`);
},
};
const ash = new window.Ash(routes, events);
</script>
</body>
</html>