{% comment %} Recursive partial for a single category node. Context variables (passed via {% include … with … %}) ------------------------------------------------------ node : dict with keys "category", "forms", "children" form_url_name : URL name for the "Fill Out Form" link depth : integer nesting depth (0 = top-level) accordion_id : id attribute of the *parent* accordion element (for data-bs-parent) {% endcomment %} {% with cat=node.category cat_id="cat-"|add:node.category.slug sub_id="sub-"|add:node.category.slug %}

{% if cat.description and depth == 0 %}

{{ cat.description }}

{% endif %} {# ---- Direct forms ---- #} {% if node.forms %}
{% for form in node.forms %}
{{ form.name }}

{{ form.description|striptags|truncatewords:20 }}

{% endfor %}
{% endif %} {# ---- Child sub-categories (recursive) ---- #} {% if node.children %}
{% for child_node in node.children %} {% include "django_forms_workflows/_category_node.html" with node=child_node depth=depth|add:1 accordion_id=sub_id %} {% endfor %}
{% endif %}
{% endwith %}