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
Copy file name to clipboardExpand all lines: docs/source/slot.md
+109-3Lines changed: 109 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -118,9 +118,9 @@ Notes:
118
118
<ahref="/">Post 2</a>
119
119
```
120
120
121
-
## Linking slots with other component
121
+
## Connect other component in the slot
122
122
123
-
This is a very powerful feature, please read it carefully.
123
+
This is the **killer feature**, so please read it carefully.
124
124
125
125
Let's update the `BlogComponent` again
126
126
@@ -160,7 +160,7 @@ class BlogComponent(component.Component):
160
160
Notes:
161
161
162
162
1. We added a `HeaderComponent`, which accept a `classes` argument
163
-
2.`header = RendersOneField(required=True, component='header')` means when `{{ self.header.value }}` is rendered, it would use the `HeaderComponent` to render the content.
163
+
2.`header = RendersOneField(required=True, component='header')` means when `{{ self.header.value }}` is rendered, it would use the `HeaderComponent`component to render the content.
164
164
165
165
```django
166
166
{% component "blog" as blog_component %}
@@ -236,3 +236,109 @@ class PostComponent(component.Component):
236
236
<h1>{{ self.post.title }}</h1>
237
237
"""
238
238
```
239
+
240
+
## Separation of concerns
241
+
242
+
The slot field and the `component` argument can help us build components with separation of concerns.
243
+
244
+
With `component` argument, we can **connect** components together, in clean way.
245
+
246
+

247
+
248
+
## Component argument in slot field
249
+
250
+
`component` in `RendersOneField` or `RendersManyField` supports many variable types.
0 commit comments