{% comment %} Card Component - Unified Django Template Version of shadcn/ui Card A flexible card container with optional header, content, and footer sections. Uses design tokens for consistent styling. Usage Examples: Basic card with title: {% include 'components/ui/card.html' with title='Card Title' content='Card content here' %} Card with all sections: {% include 'components/ui/card.html' with title='Title' description='Subtitle' body_content='

Content

' footer_content='' %} Card with custom header: {% include 'components/ui/card.html' with header_content='
Custom header
' content='Content' %} Card with block content (for more complex layouts): {% include 'components/ui/card.html' with title='Title' %} {% block card_content %} Complex content here {% endblock %} Parameters: - title: Card title text - description: Card subtitle/description text - header_content: HTML content for the header area (sanitized) - content: Main content (sanitized) - body_content: Alias for content (sanitized) - footer_content: Footer content (sanitized) - footer: Alias for footer_content (sanitized) - header: Alias for header_content (sanitized) - class: Additional CSS classes for the card container - id: Element ID Security: All content variables are sanitized using the sanitize filter to prevent XSS attacks. Only trusted HTML elements and attributes are allowed. {% endcomment %} {% load safe_html %}
{# Header Section #} {% if title or description or header_content or header %}
{% if title %}

{{ title }}

{% endif %} {% if description %}

{{ description }}

{% endif %} {% if header_content %} {{ header_content|sanitize }} {% elif header %} {{ header|sanitize }} {% endif %}
{% endif %} {# Content Section #} {% if content or body_content %}
{% if content %} {{ content|sanitize }} {% endif %} {% if body_content %} {{ body_content|sanitize }} {% endif %} {% block card_content %}{% endblock %}
{% else %} {# Allow block content even without content parameter #}
{% block card_content_fallback %}{% endblock %}
{% endif %} {# Footer Section #} {% if footer_content or footer %}
{% if footer_content %} {{ footer_content|sanitize }} {% elif footer %} {{ footer|sanitize }} {% endif %}
{% endif %}