mirror of
https://github.com/django-components/django-components.git
synced 2025-11-06 17:49:29 +00:00
| .. | ||
| 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"),
]
