docs: Syntax highlighting for mkdocs (#984)

* feat:forward context processors variables in context in ISOLATED mode

	provide context_processors_data property to Component to access those variables in Component

* refactor: internalize RequestContext and pass HttpRequest internally

* docs: document HttpRequest and context processors

* docs: use djc_py code blocks for component definitions

---------

Co-authored-by: Lilian Durey <dureylilian@gmail.com>
This commit is contained in:
Juro Oravec 2025-02-20 11:47:14 +01:00 committed by GitHub
parent 1f7e28db22
commit 314ec77d3d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 142 additions and 76 deletions

View file

@ -7,7 +7,7 @@ associated with components, and how we render them.
1. First of all, when we consider a component, it has two kind of dependencies - the "inlined" JS and CSS, and additional linked JS and CSS via `Media.js/css`:
```py
```djc_py
from django_components import Component, types
class MyTable(Component):

View file

@ -15,7 +15,7 @@
```
And components that make use of `abc.html` via `include` or `extends`:
```py
```djc_py
from django_components import Component, register
@register("my_comp_extends")
@ -66,7 +66,7 @@
```py
@register("my_comp")
class MyComp(Component):
template_file = "abc.html"
template_file = "abc.html"
```
Then:
@ -110,37 +110,34 @@
uses `extends`. In that case, just as you would expect, the `block inner` inside
`abc.html` will render `OVERRIDEN`:
````py
```djc_py
@register("my_comp")
class MyComp(Component):
template_file = """
{% extends "abc.html" %}
{% block inner %}
OVERRIDEN
{% endblock %}
"""
```
````
template = """
{% extends "abc.html" %}
{% block inner %}
OVERRIDEN
{% endblock %}
"""
```
4. This is where it gets interesting (but still intuitive). You can insert even
new `slots` inside these "overriding" blocks:
```py
```djc_py
@register("my_comp")
class MyComp(Component):
template_file = """
{% extends "abc.html" %}
template = """
{% extends "abc.html" %}
{% load component_tags %}
{% block "inner" %}
OVERRIDEN
{% slot "new_slot" %}
hello
{% endslot %}
{% endblock %}
"""
{% load component_tags %}
{% block "inner" %}
OVERRIDEN
{% slot "new_slot" %}
hello
{% endslot %}
{% endblock %}
"""
```
And you can then pass fill for this `new_slot` when rendering the component: