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

@ -105,7 +105,7 @@ For live examples, see the [Community examples](../../overview/community.md#comm
It's also a good idea to have a common prefix for your components, so they can be easily distinguished from users' components. In the example below, we use the prefix `my_` / `My`.
```py
```djc_py
from typing import Dict, NotRequired, Optional, Tuple, TypedDict
from django_components import Component, SlotFunc, register, types

View file

@ -106,7 +106,7 @@ Then navigate to these URLs:
### 1. Define document HTML
```py title="[root]/components/demo.py"
```djc_py title="[root]/components/demo.py"
from django_components import Component, types
# HTML into which a fragment will be loaded using HTMX
@ -141,7 +141,7 @@ class MyPage(Component):
### 2. Define fragment HTML
```py title="[root]/components/demo.py"
```djc_py title="[root]/components/demo.py"
class Frag(Component):
def get(self, request):
return self.render_to_response(
@ -184,7 +184,7 @@ urlpatterns = [
### 1. Define document HTML
```py title="[root]/components/demo.py"
```djc_py title="[root]/components/demo.py"
from django_components import Component, types
# HTML into which a fragment will be loaded using AlpineJS
@ -225,7 +225,7 @@ class MyPage(Component):
### 2. Define fragment HTML
```py title="[root]/components/demo.py"
```djc_py title="[root]/components/demo.py"
class Frag(Component):
def get(self, request):
# IMPORTANT: Don't forget `type="fragment"`
@ -281,7 +281,7 @@ urlpatterns = [
### 1. Define document HTML
```py title="[root]/components/demo.py"
```djc_py title="[root]/components/demo.py"
from django_components import Component, types
# HTML into which a fragment will be loaded using JS
@ -321,7 +321,7 @@ class MyPage(Component):
### 2. Define fragment HTML
```py title="[root]/components/demo.py"
```djc_py title="[root]/components/demo.py"
class Frag(Component):
def get(self, request):
return self.render_to_response(

View file

@ -107,7 +107,7 @@ have all the keys that were passed to the `provide` tag.
## Full example
```py
```djc_py
@register("child")
class ChildComponent(Component):
template = """

View file

@ -27,7 +27,7 @@ the locations by inserting following Django template tags:
So if you have a component with JS and CSS:
```python
```djc_py
from django_components import Component, types
class MyButton(Component):