cyberstorm/book/macros.tera

67 lines
2.3 KiB
Plaintext
Raw Normal View History

2021-03-03 02:38:15 +00:00
{% macro content(content) %}
{%- set trimmed = content | trim -%}
{%- if trimmed | length == 0 %}No description{% else %}{{ trimmed }}{% endif -%}
{% endmacro content %}
2021-03-02 04:17:16 +00:00
{% macro references(refs) %}
{%- if refs | length == 0 %}No references{% endif -%}
{%- for ref in refs -%}
- {{ ref | autolink }}
{% endfor -%}
{% endmacro references %}
2021-03-03 02:38:15 +00:00
{% macro doc_title(doc) -%}
{{ doc.name }} <small>([edit]({{ doc.id | domain_id_link(for="edit") }}))</small>
{%- endmacro doc_title %}
2021-03-02 04:17:16 +00:00
2021-03-03 02:38:15 +00:00
{% macro doc_details(doc) -%}
| Title | {{ doc.name }} |
2021-03-02 04:17:16 +00:00
|:---------------------------:|:------------------------|
2021-03-03 02:38:15 +00:00
{{ self::doc_details_next(title="ID", value=doc.id)}}
{%- endmacro doc_details %}
2021-03-02 04:17:16 +00:00
2021-03-03 02:38:15 +00:00
{% macro doc_details_next(title, value) -%}
2021-03-02 04:17:16 +00:00
| **{{ title }}** | {{ value }} |
2021-03-03 02:38:15 +00:00
{%- endmacro doc_details_next %}
2021-03-02 04:17:16 +00:00
2021-03-03 02:38:15 +00:00
{% macro doc_details_authors(authors) -%}
{{ self::doc_details_next(title="Authors", value=authors | join )}}
{%- endmacro doc_details_authors %}
2021-03-02 04:17:16 +00:00
2021-03-03 02:38:15 +00:00
{% macro doc_details_tags(tags) -%}
2021-03-02 04:17:16 +00:00
{% if tags | length == 0 -%}
2021-03-03 02:38:15 +00:00
{{ self::doc_details_next(title="Tags", value="No tags") }}
2021-03-02 04:17:16 +00:00
{%- else -%}
2021-03-03 02:38:15 +00:00
{{ self::doc_details_next(title="Tags", value=tags | join) }}
2021-03-02 04:17:16 +00:00
{%- endif %}
2021-03-03 02:38:15 +00:00
{%- endmacro doc_details_tags %}
2021-03-02 04:17:16 +00:00
2021-03-03 02:38:15 +00:00
{% macro doc_rich_link(doc) -%}
{{ doc.name }} ([{{ doc.id }}]({{ global(key="site_url")}}{{ doc.id | domain_id_link }}))
{%- endmacro doc_rich_link %}
2021-03-02 04:17:16 +00:00
2021-03-02 05:12:30 +00:00
{% macro summary_table(instances) -%}
2021-03-02 04:17:16 +00:00
| ID | Name |
|:---------------------------:|:------------------------|
{% for item in instances -%}
2021-03-03 02:38:15 +00:00
| [{{ item.id }}]({{ global(key="site_url") }}{{ item.id | domain_id_link }}) | {{ item.name }} |
2021-03-02 04:17:16 +00:00
{% endfor %}
2021-03-02 05:12:30 +00:00
{%- 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 %}
2021-03-03 02:38:15 +00:00
- [{{ id_parts.model | capitalize }}](./{{ item.id | domain_id_link(for="model") }})
2021-03-02 05:12:30 +00:00
{%- endif %}
2021-03-03 02:38:15 +00:00
- [{{ item.name }}](./{{ item.id | domain_id_link }})
2021-03-02 05:12:30 +00:00
{%- endfor -%}
2021-03-03 02:38:15 +00:00
{% endmacro summary_list %}