{#- chirp-ui: Params table component API parameters table (Name, Type, Default, Description). Data-in: rows = [{name, type, default?, description}]. Standard for API docs (OpenAPI, Sphinx). Framework-agnostic. Usage: from "chirpui/params_table.html" import params_table params_table(rows=params, title="Parameters") params_table(rows=params, title="Returns", columns=["name", "type", "description"]) -#} {% def params_table(rows, title=none, columns=none, cls="") %} {% set default_columns = ["name", "type", "default", "description"] %} {% set cols = columns if columns else default_columns %}
{% if title %}

{{ title }}

{% end %}
{% for col in cols %} {% end %} {% for row in rows %} {% for col in cols %} {% end %} {% end %}
{{ col | capitalize }}
{% if col == "name" %} {{ row.get("name", "") }} {% elif col == "type" %} {{ row.get("type", "") }} {% elif col == "default" %} {% if row.get("default") is not none and row.get("default") != "" %} {{ row.default }} {% else %} {% end %} {% elif col == "description" %} {{ row.get("description", "") }} {% else %} {{ row.get(col, "") }} {% end %}
{% end %}