{#- chirp-ui: ASCII Table Tables rendered with box-drawing characters instead of CSS borders. Usage: from "chirpui/ascii_table.html" import ascii_table, ascii_row call ascii_table(headers=["Name", "Status", "Latency"]) ascii_row("api-gateway", "Healthy", "23ms") ascii_row("auth-service", "Healthy", "41ms") end Per-column alignment: call ascii_table(headers=["Service", "Status", "Requests"], align=["left", "center", "right"]) ascii_row("api-gateway", "Healthy", "12,847") end Variants: single (default), double, heavy, rounded. Compact mode: compact=true for tighter spacing. Striped rows: striped=true. Caption: use the caption slot. -#} {% def ascii_table(headers=none, variant="single", align=none, compact=false, striped=false, sticky_header=false, cls="") %} {% set variant = variant | validate_variant(("single", "double", "heavy", "rounded"), "single") %} {% set compact_class = " chirpui-ascii-table--compact" if compact else "" %} {% set striped_class = " chirpui-ascii-table--striped" if striped else "" %} {% set sticky_class = " chirpui-ascii-table--sticky" if sticky_header else "" %}
{% if headers %}
{% for header in headers %} {% set col_align = align[loop.index0] if align and loop.index0 < align | length else "" %} {{ header }} {% end %}
{% end %}
{% slot %}
{% end %} {% def ascii_row(*cells, align=none) %}
{% for cell in cells %} {% set col_align = align[loop.index0] if align and loop.index0 < align | length else "" %} {{ cell }} {% end %}
{% end %}