You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `update` asynchronous method exposes the following properties :
53
51
*`bindingsCount` (number) : The number of bindings detected
54
52
*`model` (object) : The reactive model (see below)
53
+
*`done` (function) : Returns a promise being fulfilled when the last update completes (see below).
54
+
55
+
Upon `update` invocation, the returned [promise is fulfilled](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) when the DOM update is **completed**.
55
56
56
57
### 4. Update the section by passing a context object
57
58
58
59
```JavaScript
59
60
awaitupdate({
60
61
title:'My TODO list',
61
62
items: [{
62
-
done:false,
63
+
done:true,
63
64
text:'Forget about heavy frameworks'
64
65
}, {
65
-
done:true,
66
+
done:false,
66
67
text:'Adopt punybind'
67
68
}]
68
69
})
69
70
```
70
71
72
+
*Or use the reactive model (see below).*
73
+
71
74
### 5. Enjoy !
72
75
76
+
## Supported syntaxes
77
+
78
+
### Text and attribute binding
79
+
80
+
Text nodes and attribute values leverage binding using the `{{ expression }}` syntax.
81
+
82
+
The `expression` is evaluated with the properties of the contextual object.
83
+
84
+
It is possible to mix static content with computed one but *any* error **clears** the whole value.
85
+
86
+
### Iterators
87
+
88
+
Iterators allow the repetition of elements.
89
+
90
+
An iterator is declared **on** the element to repeat using the special attribute `{{for}}` with the value being either :
91
+
*`{{for}}="item of expression"`
92
+
*`{{for}}="item, index of expression"`
93
+
94
+
Where :
95
+
*`item` is the contextual property receiving the value of the current iteration (to use in the subsequent bindings),
96
+
*`index` is the contextual property receiving the index of the current iteration (0-based),
97
+
*`expression` must evaluate to an [iterable object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols).
98
+
99
+
### Conditionals
100
+
101
+
Conditionals rule the rendering of elements.
102
+
103
+
They can form an `if` / `elseif` / `else` chain. Their expression must evaluate to a [truthy value](https://developer.mozilla.org/en-US/docs/Glossary/Truthy) to enable rendering.
104
+
105
+
To work properly, the attributes must be set **on contiguous sibling elements** :
106
+
*`{{if}}="expression"` : must be the first element of the chain,
107
+
*`{{elseif}}="expression"` : (optional) is evaluated and rendered only if the previous `if` / `elseif` did not evaluate to a truthy value,
108
+
*`{{else}}` : (optional) terminates the chain and is rendered only if the previous `if` / `elseif` did not evaluate to a truthy value.
0 commit comments