Update indenting typo in slots_and_blocks.md (#959)

This commit is contained in:
Bernat Frangi 2025-02-09 15:29:18 +01:00 committed by GitHub
parent 61515b3454
commit fe128053c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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