mirror of
https://github.com/django-components/django-components.git
synced 2025-09-19 20:29:44 +00:00
Update indenting typo in slots_and_blocks.md
(#959)
This commit is contained in:
parent
61515b3454
commit
fe128053c9
1 changed files with 32 additions and 32 deletions
|
@ -5,44 +5,44 @@
|
||||||
template was inlined. So if the "included" template contains `slot` tags, then the component
|
template was inlined. So if the "included" template contains `slot` tags, then the component
|
||||||
uses those slots.
|
uses those slots.
|
||||||
|
|
||||||
So if you have a template `abc.html`:
|
So if you have a template `abc.html`:
|
||||||
```django
|
```django
|
||||||
<div>
|
<div>
|
||||||
hello
|
hello
|
||||||
{% slot "body" %}{% endslot %}
|
{% slot "body" %}{% endslot %}
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
And components that make use of `abc.html` via `include` or `extends`:
|
And components that make use of `abc.html` via `include` or `extends`:
|
||||||
```py
|
```py
|
||||||
from django_components import Component, register
|
from django_components import Component, register
|
||||||
|
|
||||||
@register("my_comp_extends")
|
@register("my_comp_extends")
|
||||||
class MyCompWithExtends(Component):
|
class MyCompWithExtends(Component):
|
||||||
template = """{% extends "abc.html" %}"""
|
template = """{% extends "abc.html" %}"""
|
||||||
|
|
||||||
@register("my_comp_include")
|
@register("my_comp_include")
|
||||||
class MyCompWithInclude(Component):
|
class MyCompWithInclude(Component):
|
||||||
template = """{% include "abc.html" %}"""
|
template = """{% include "abc.html" %}"""
|
||||||
```
|
```
|
||||||
|
|
||||||
Then you can set slot fill for the slot imported via `include/extends`:
|
Then you can set slot fill for the slot imported via `include/extends`:
|
||||||
|
|
||||||
```django
|
```django
|
||||||
{% component "my_comp_extends" %}
|
{% component "my_comp_extends" %}
|
||||||
{% fill "body" %}
|
{% fill "body" %}
|
||||||
123
|
123
|
||||||
{% endfill %}
|
{% endfill %}
|
||||||
{% endcomponent %}
|
{% endcomponent %}
|
||||||
```
|
```
|
||||||
|
|
||||||
And it will render:
|
And it will render:
|
||||||
```html
|
```html
|
||||||
<div>
|
<div>
|
||||||
hello
|
hello
|
||||||
123
|
123
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Slot and block
|
2. Slot and block
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue