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
Vento has a parent to child data inheritance system:
4
+
5
+
## Child templates have access to the parent's data
6
+
7
+
When a template includes another template (using [include](./6.include.md) or [layout](./7.layout.md)), the children template can access to the parent data. For example:
8
+
9
+
```vto
10
+
{{ set value = "Hello world" }}
11
+
12
+
{{ include "child.vto" }}
13
+
```
14
+
15
+
The child template can access to the parent variable:
16
+
17
+
```vto
18
+
{{ value }}
19
+
```
20
+
21
+
This doesn't happen in reverse order. A variable declared in a child component cannot be accessed by the parent template.
22
+
23
+
## Parent templates can edit children variables
24
+
25
+
Parent templates can create or modify existing variables before rendering nested templates. For example:
In this example, the parent variable modifies the `value` variable and creates the `foo` variable. These changes are only available in the context of the child template (and successive nested templates).
0 commit comments