-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
47 lines (44 loc) · 1 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
<!doctype html>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>test</title>
<script src="rpug.bundle.js"></script>
<style>
.bar, .foo, .test {
background-color: pink;
}
.test.foo.bar {
background-color: green;
}
</style>
<body>
<script type="text/rpug">
button(onclick=incClicks) click
p.test.foo(class=collection.length==2?"bar":"nonono") Click count: #{clicks}
ul
each val, index in collection
li= val
button(onclick=delItem,data=index) -
br
input(type="text",oninput-bind=ontext,value=text)
input(type="text",oninput-bind=ontext,value=text)
p= text
</script>
<script>
var collection = []
var clicks = 0
function incClicks() {
clicks += 1
collection.push(collection.length + 1)
}
function delItem(event) {
collection.splice(event.target.getAttribute("data"), 1)
}
var text = "Lorem ipsum"
function ontext(event) {
text = event.target.value
}
var rpug = require("rpug")
var context = rpug.context()
context.findAndMount()
</script>
</body>