refactor: Update docs and tests to use get_template_data() (#1161)

* refactor: update docs and tests to use get_template_data()

* refactor: fix linting

* docs: add note about difference between the two methods
This commit is contained in:
Juro Oravec 2025-05-03 12:04:10 +02:00 committed by GitHub
parent c69980493d
commit 28b61c1609
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
69 changed files with 795 additions and 725 deletions

View file

@ -56,7 +56,7 @@ class ContextBehavior(str, Enum):
That is, they enrich the context, and pass it along.
1. Component fills use the context of the component they are within.
2. Variables from [`Component.get_context_data()`](../api#django_components.Component.get_context_data)
2. Variables from [`Component.get_template_data()`](../api#django_components.Component.get_template_data)
are available to the component fill.
**Example:**
@ -71,7 +71,7 @@ class ContextBehavior(str, Enum):
{% endwith %}
```
and this context returned from the `Component.get_context_data()` method
and this context returned from the `Component.get_template_data()` method
```python
{ "my_var": 123 }
```
@ -98,7 +98,7 @@ class ContextBehavior(str, Enum):
"""
This setting makes the component fills behave similar to Vue or React, where
the fills use EXCLUSIVELY the context variables defined in
[`Component.get_context_data()`](../api#django_components.Component.get_context_data).
[`Component.get_template_data()`](../api#django_components.Component.get_template_data).
**Example:**
@ -112,7 +112,7 @@ class ContextBehavior(str, Enum):
{% endwith %}
```
and this context returned from the `get_context_data()` method
and this context returned from the `get_template_data()` method
```python
{ "my_var": 123 }
```