mirror of
https://github.com/django-components/django-components.git
synced 2025-11-07 01:56:42 +00:00
|
Some checks are pending
Docs - build & deploy / docs (push) Waiting to run
Run tests / build (ubuntu-latest, 3.10) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.11) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.12) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.13) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.8) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.9) (push) Waiting to run
Run tests / build (windows-latest, 3.10) (push) Waiting to run
Run tests / build (windows-latest, 3.11) (push) Waiting to run
Run tests / build (windows-latest, 3.12) (push) Waiting to run
Run tests / build (windows-latest, 3.13) (push) Waiting to run
Run tests / build (windows-latest, 3.8) (push) Waiting to run
Run tests / build (windows-latest, 3.9) (push) Waiting to run
Run tests / test_docs (3.13) (push) Waiting to run
Run tests / test_sampleproject (3.13) (push) Waiting to run
|
||
|---|---|---|
| .. | ||
| images | ||
| component.py | ||
| page.py | ||
| README.md | ||
| test_example_recursive.py | ||
Recursion
Unlike other frameworks, django-components handles templates of any depth. 100 nested components? Not a problem!
In this example, the Recursion will recursively render itself 100 times.
{% component "recursion" / %}
This will produce a deeply nested structure of divs, with each level indicating its depth in the recursion.
Definition
--8<-- "docs/examples/recursion/component.py"
Example
To see the component in action, you can set up a view and a URL pattern as shown below.
views.py
--8<-- "docs/examples/recursion/page.py"
urls.py
from django.urls import path
from examples.pages.recursion import RecursionPage
urlpatterns = [
path("examples/recursion", RecursionPage.as_view(), name="recursion"),
]
