# Component Templates Dpgstack uses django-cotton for reusable HTML components. Components live in `templates/cotton/`: ## Creating a component ```html ``` ## Using a component ```html Click me ``` ## Component patterns - `{{ slot }}` - Default content slot - `` - Named slots - `:prop="value"` - Pass dynamic values (Alpine syntax) - `{{ attrs }}` - Merge extra attributes from caller ## Model Templates Model templates define how model data is displayed. Each model has a template in `templates//`. ## Template Structure Templates use django-cotton components and partialdef for fragments: ```html {% partialdef table_row %} {% endpartialdef %} {% partialdef edit_row %} {% endpartialdef %} {% for piece in queryset %} {% partial table_row %} {% endfor %} ``` ## Key patterns - `{{ piece|get_field:field }}` - Access model field value - `{{ form|get_item:field_name }}` - Access form field - `{{ request.GET.order_by|figure_order:field }}` - Sorting indicator - `{% querystring action='get-edit-row' %}` - Append query params