-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.jade
81 lines (76 loc) · 2.45 KB
/
example.jade
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
!!! 5
html
head
script(type="text/javascript",src="./build/build.js")
script(type="text/javascript").
function init() {
var syncModel = require('sync-model');
var model = require('component-model');
var User = model('user')
.attr('name', {
required: true,
type: 'string'
})
.attr('email', {
required: true,
type: 'string',
format: 'email'
})
.attr('address', {
type: 'object',
properties: {
street: {
required: true,
type: 'string'
},
zipcode: {
required: true,
type: 'string'
},
city: {
required: true,
type: 'string'
}
}
})
.attr('orders', {
type: 'array',
items: {
type: 'object',
properties: {
amount: {
required: true,
type: 'integer'
},
name: {
required: true,
type: 'string'
}
}
}
});
function callback (errors) {
console.log('validaton errors: ', errors);
}
var user = syncModel(document.querySelector('form'), User, callback, this);
console.log(user);
};
body(onload="init()")
form
span Name:
input(name="name",value="Hans")
br
span Email:
input(name="email",value="h@ns")
br
span Address:
input(name="address.street",value="streetname")
input(name="address.zipcode",value="zipcode")
input(name="address.city",value="city")
br
span Orders:
input(name="orders.0.amount",value="1")
input(name="orders.0.name",value="Socks")
br
input(name="orders.1.amount",value="2")
input(name="orders.1.name",value="Shoes")