cyberstorm/book/macros.tera

67 lines
2.3 KiB
Plaintext

{% macro content(content) %}
{%- set trimmed = content | trim -%}
{%- if trimmed | length == 0 %}No description{% else %}{{ trimmed }}{% endif -%}
{% endmacro content %}
{% macro references(refs) %}
{%- if refs | length == 0 %}No references{% endif -%}
{%- for ref in refs -%}
- {{ ref | autolink }}
{% endfor -%}
{% endmacro references %}
{% macro doc_title(doc) -%}
{{ doc.name }} <small>([edit]({{ doc.id | domain_id_link(for="edit") }}))</small>
{%- endmacro doc_title %}
{% macro doc_details(doc) -%}
| Title | {{ doc.name }} |
|:---------------------------:|:------------------------|
{{ self::doc_details_next(title="ID", value=doc.id)}}
{%- endmacro doc_details %}
{% macro doc_details_next(title, value) -%}
| **{{ title }}** | {{ value }} |
{%- endmacro doc_details_next %}
{% macro doc_details_authors(authors) -%}
{{ self::doc_details_next(title="Authors", value=authors | join )}}
{%- endmacro doc_details_authors %}
{% macro doc_details_tags(tags) -%}
{% if tags | length == 0 -%}
{{ self::doc_details_next(title="Tags", value="No tags") }}
{%- else -%}
{{ self::doc_details_next(title="Tags", value=tags | join) }}
{%- endif %}
{%- endmacro doc_details_tags %}
{% macro doc_rich_link(doc) -%}
{{ doc.name }} ([{{ doc.id }}]({{ global(key="site_url")}}{{ doc.id | domain_id_link }}))
{%- endmacro doc_rich_link %}
{% macro summary_table(instances) -%}
| ID | Name |
|:---------------------------:|:------------------------|
{% for item in instances -%}
| [{{ item.id }}]({{ global(key="site_url") }}{{ item.id | domain_id_link }}) | {{ item.name }} |
{% endfor %}
{%- endmacro summary_table %}
{% macro summary_list(instances) %}
{%- set last_domain = "" -%}
{%- set last_model = "" -%}
{%- for item in summary -%}
{%- set id_parts = item.id | domain_id -%}
{%- if last_domain != id_parts.domain -%}
{%- set_global last_domain = id_parts.domain %}
# {{ id_parts.domain | capitalize }}
{%- endif -%}
{%- if last_model != id_parts.model -%}
{%- set_global last_model = id_parts.model %}
- [{{ id_parts.model | capitalize }}](./{{ item.id | domain_id_link(for="model") }})
{%- endif %}
- [{{ item.name }}](./{{ item.id | domain_id_link }})
{%- endfor -%}
{% endmacro summary_list %}