mirror of
https://github.com/django-components/django-components.git
synced 2025-08-04 06:18:17 +00:00
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:
parent
1f7e28db22
commit
314ec77d3d
26 changed files with 142 additions and 76 deletions
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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 = """
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue