vessel/doc/temple-example/templates/macros.lpt
2025-06-25 15:44:28 +03:00

17 lines
519 B
Text

{% macro list_items(lst, depth=1) %}
{% if depth > 0 && isiter(lst) %}
<ul>
{% for it : enumerate(lst) %}
{% if isiter(it.value) %}
<li>{{ it.index }}: {{ list_items(it.value, depth - 1) }}</li>
{% else %}
<li>{{ it.value }}</li>
{% end %}
{% end %}
</ul>
{% else %}
{{ lst }}
{% end %}
{% end %}
{% macro table_row(key, value) %}<tr><th>{{ key }}</th><td>{{ stringify(value) }}</td></tr>{% end %}