diff --git a/docs/concepts/advanced/authoring_component_libraries.md b/docs/concepts/advanced/authoring_component_libraries.md
index 242bbbb5..9d7f8b03 100644
--- a/docs/concepts/advanced/authoring_component_libraries.md
+++ b/docs/concepts/advanced/authoring_component_libraries.md
@@ -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
diff --git a/docs/concepts/advanced/html_tragments.md b/docs/concepts/advanced/html_tragments.md
index 1b93c167..42f6d04c 100644
--- a/docs/concepts/advanced/html_tragments.md
+++ b/docs/concepts/advanced/html_tragments.md
@@ -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(
diff --git a/docs/concepts/advanced/provide_inject.md b/docs/concepts/advanced/provide_inject.md
index ac73688d..68954d0e 100644
--- a/docs/concepts/advanced/provide_inject.md
+++ b/docs/concepts/advanced/provide_inject.md
@@ -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 = """
diff --git a/docs/concepts/advanced/rendering_js_css.md b/docs/concepts/advanced/rendering_js_css.md
index 364232dc..3772d2d5 100644
--- a/docs/concepts/advanced/rendering_js_css.md
+++ b/docs/concepts/advanced/rendering_js_css.md
@@ -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):
diff --git a/docs/concepts/fundamentals/component_context_scope.md b/docs/concepts/fundamentals/component_context_scope.md
index adc5f33d..fca79315 100644
--- a/docs/concepts/fundamentals/component_context_scope.md
+++ b/docs/concepts/fundamentals/component_context_scope.md
@@ -85,9 +85,9 @@ This has two modes:
Consider this example:
- ```python
+ ```djc_py
class Outer(Component):
- template = \"\"\"
+ template = """
{% component "inner" %}
{% fill "content" %}
@@ -95,7 +95,7 @@ This has two modes:
{% endfill %}
{% endcomponent %}
- \"\"\"
+ """
```
- `"django"` - `my_var` has access to data from `get_context_data()` of both `Inner` and `Outer`.
@@ -108,7 +108,7 @@ This has two modes:
Given this template:
-```python
+```djc_py
@register("root_comp")
class RootComp(Component):
template = """
@@ -148,7 +148,7 @@ all the data defined in the outer layers, like the `{% with %}` tag.
Given this template:
-```python
+```djc_py
class RootComp(Component):
template = """
{% with cheese="feta" %}
diff --git a/docs/concepts/fundamentals/components_as_views.md b/docs/concepts/fundamentals/components_as_views.md
index c950b1db..21b181e2 100644
--- a/docs/concepts/fundamentals/components_as_views.md
+++ b/docs/concepts/fundamentals/components_as_views.md
@@ -19,7 +19,7 @@ Components can now be used as views:
Here's an example of a calendar component defined as a view:
-```python
+```djc_py
# In a file called [project root]/components/calendar.py
from django_components import Component, ComponentView, register
diff --git a/docs/concepts/fundamentals/components_in_python.md b/docs/concepts/fundamentals/components_in_python.md
index 5afd54d5..475add38 100644
--- a/docs/concepts/fundamentals/components_in_python.md
+++ b/docs/concepts/fundamentals/components_in_python.md
@@ -9,7 +9,7 @@ Components can be rendered outside of Django templates, calling them as regular
The component class defines `render` and `render_to_response` class methods. These methods accept positional args, kwargs, and slots, offering the same flexibility as the `{% component %}` tag:
-```py
+```djc_py
class SimpleComponent(Component):
template = """
{% load component_tags %}
diff --git a/docs/concepts/fundamentals/defining_js_css_html_files.md b/docs/concepts/fundamentals/defining_js_css_html_files.md
index c55145b6..a34d9242 100644
--- a/docs/concepts/fundamentals/defining_js_css_html_files.md
+++ b/docs/concepts/fundamentals/defining_js_css_html_files.md
@@ -28,7 +28,7 @@ HTML / JS / CSS with a component:
However, you can freely mix these for different languages:
- ```py
+ ```djc_py
class MyTable(Component):
template: types.django_html = """
diff --git a/docs/concepts/fundamentals/html_attributes.md b/docs/concepts/fundamentals/html_attributes.md
index 64e04b23..eeeea8ac 100644
--- a/docs/concepts/fundamentals/html_attributes.md
+++ b/docs/concepts/fundamentals/html_attributes.md
@@ -256,7 +256,7 @@ Then:
## Full example for `html_attrs`
-```py
+```djc_py
@register("my_comp")
class MyComp(Component):
template: t.django_html = """
diff --git a/docs/concepts/fundamentals/http_request.md b/docs/concepts/fundamentals/http_request.md
index 91f95a53..57947de0 100644
--- a/docs/concepts/fundamentals/http_request.md
+++ b/docs/concepts/fundamentals/http_request.md
@@ -78,7 +78,7 @@ rendered = template.render(RequestContext(request, {}))
The data from context processors is automatically available within the component's template.
-```python
+```djc_py
class MyComponent(Component):
template = """
diff --git a/docs/concepts/fundamentals/single_file_components.md b/docs/concepts/fundamentals/single_file_components.md
index 73f9e870..708d2925 100644
--- a/docs/concepts/fundamentals/single_file_components.md
+++ b/docs/concepts/fundamentals/single_file_components.md
@@ -9,7 +9,7 @@ For example, here's the calendar component from
the [Getting started](../../getting_started/your_first_component.md) tutorial,
defined in a single file:
-```python title="[project root]/components/calendar.py"
+```djc_py title="[project root]/components/calendar.py"
from django_components import Component, register, types
@register("calendar")
diff --git a/docs/concepts/fundamentals/slots.md b/docs/concepts/fundamentals/slots.md
index f1ba610a..f9ea4f68 100644
--- a/docs/concepts/fundamentals/slots.md
+++ b/docs/concepts/fundamentals/slots.md
@@ -469,7 +469,7 @@ _Added in version 0.76_:
Consider a component with slot(s). This component may do some processing on the inputs, and then use the processed variable in the slot's default template:
-```py
+```djc_py
@register("my_comp")
class MyComp(Component):
template = """
@@ -498,7 +498,7 @@ Using scoped slots consists of two steps:
To pass the data to the `slot` tag, simply pass them as keyword attributes (`key=value`):
-```py
+```djc_py
@register("my_comp")
class MyComp(Component):
template = """
@@ -649,14 +649,14 @@ So it's possible to define a `name` key on a dictionary, and then spread that on
You can dynamically pass all slots to a child component. This is similar to
[passing all slots in Vue](https://vue-land.github.io/faq/forwarding-slots#passing-all-slots):
-```py
+```djc_py
class MyTable(Component):
def get_context_data(self, *args, **kwargs):
return {
"slots": self.input.slots,
}
- template: """
+ template = """
{% component "child" %}
{% for slot_name in slots %}
diff --git a/docs/concepts/fundamentals/subclassing_components.md b/docs/concepts/fundamentals/subclassing_components.md
index dc376273..e946b74c 100644
--- a/docs/concepts/fundamentals/subclassing_components.md
+++ b/docs/concepts/fundamentals/subclassing_components.md
@@ -25,7 +25,7 @@ inheritance follows these rules:
For example:
-```python
+```djc_py
class BaseCard(Component):
template = """
@@ -37,7 +37,7 @@ class BaseCard(Component):
border: 1px solid gray;
}
"""
- js = "console.log('Base card loaded');"
+ js = """console.log('Base card loaded');"""
# This class overrides parent's template, but inherits CSS and JS
class SpecialCard(BaseCard):
@@ -94,7 +94,7 @@ All other attributes and methods (including the [`Component.View`](../../referen
For example:
-```python
+```djc_py
class BaseForm(Component):
template = """