ansible-doctor/ansibledoctor/templates/readme/_vars_tabulated.j2

37 lines
1.2 KiB
Plaintext
Raw Normal View History

{% set var = role.var | default({}) %}
{% if var %}
## Default Variables
{% set columns = ["variable", "default", "description", "type", "deprecated", "example"] %}
{% set found_columns = ["variable", "default"] + var.values() | map("list") | sum(start=["key"]) | unique | list %}
{% for c in columns %}
{% if c in found_columns %}
| {{ c | capitalize }} {# trimnewline #}
{% endif %}
{% endfor %}
|
{% for c in columns %}
{% if c in found_columns %}
| {{ "-" * (c | length) }} {# trimnewline #}
{% endif %}
{% endfor %}
|
{% for key, item in var | dictsort %}
| {{ key }} {# trimnewline #}
| {{ (item.value | default({}))[key] | default }} {# trimnewline #}
{% if "description" in found_columns %}
| {{ item.description | default([]) | safe_join("<br>") | replace("\n", "<br>") | replace("|", "\|") }} {# trimnewline #}
{% endif %}
{% if "type" in found_columns %}
| {{ item.type | default([]) | join("<br>") }} {# trimnewline #}
{% endif %}
{% if "deprecated" in found_columns %}
| {{ item.deprecated | default }} {# trimnewline #}
{% endif %}
{% if "example" in found_columns %}
| {{ item.example | default([]) | safe_join("<br>") | replace("\n", "<br>") | replace("|", "\|") }} {# trimnewline #}
{% endif %}
|
{% endfor %}
{% endif %}