{# ================================================================================ Element Card Macro (Kida-Native) ================================================================================ Renders a single autodoc element as a card (command, class, function, endpoint, etc.). USAGE: {% from 'autodoc/partials/_macros/element-card.html' import element_card %} {{ element_card(child) }} {{ element_card(child, card_type='command') }} ARGS: child: DocElement to render (required) card_type: Override element type for styling (optional) NOTE: DocElement.href is pre-computed during page building with baseurl included. Templates should use {{ child.href }} directly for links. KIDA FEATURES USED: - Optional chaining (?.) for safe attribute access - Null coalescing (??) for defaults ================================================================================ #} {% def element_card(child, card_type=none) %} {# Extract values with null-safety using {% let %} #} {% let child_type = card_type ?? child?.element_type ?? 'unknown' %} {% let child_url = child?.href ?? '#' %} {% let child_name = child?.name ?? 'Unknown' %} {% let child_desc = child?.description ?? '' %} {% let child_meta = child?.metadata ?? {} %} {% let http_method = child_meta?.method ?? '' %} {% match child_type, http_method %} {% case 'endpoint', method if method %} {{ method | upper }} {% end %} {{ child_name }} {% if child_desc %} {{ child_desc | excerpt_for_card(child_name) | excerpt(100) }} {% end %} {% end %}