www-from-model/page_templates/project.md.j2
Michael Hanke bad4a6c0d6
All checks were successful
Deploy on webserver / Build site and deploy on success (push) Successful in 1m33s
rf: simplify project page template, avoid empty headings
The to-be-rendered items are now determined upfront, and the
inclusion of a heading is made conditional on the presence
of any item.
2026-05-19 08:33:53 +02:00

59 lines
2.4 KiB
Django/Jinja

{% extends "page.md.j2" %}
{%- set objectives = influenced_by | selectattr("object.schema_type", "eq", "xyzri:XYZObjective") | selectattr("ended", "undefined") | list -%}
{%- set curr_associated = associated_with | selectattr("object.schema_type", "eq", "xyzri:XYZPerson") | selectattr("ended", "undefined") | list -%}
{%- set prev_associated = associated_with | selectattr("object.schema_type", "eq", "xyzri:XYZPerson") | selectattr("ended", "defined") | list -%}
{% block frontmatter -%}
title: "{{ title }}"
{{ taxonomy_terms('projects', 'xyzri:XYZProject', parts, typeattr='schema_type', pidattr='pid') -}}
{{ taxonomy_terms('objectives', 'xyzri:XYZObjective', influenced_by) -}}
{{ taxonomy_terms('persons', 'xyzri:XYZPerson', associated_with) -}}
{{ taxonomy_terms('instruments', 'xyzri:XYZInstrument', generated, typeattr='schema_type', pidattr='pid') -}}
{% endblock -%}
{% block content -%}
{{ description }}
{% if part_of %}## Part of
{% for item in part_of -%}
- [{{ item.title }}](/{{ item.pid.replace('xyzrins:', '') }})
{% endfor %}
{% endif -%}
{% if objectives -%}
## Objectives
{% for inf in objectives -%}
- [{{ inf.object.title }}](/{{ inf.object.pid|replace('xyzrins:', '') }}) ({%for role in inf.roles %}{{ ', ' if not loop.first }}{{ role.display_label|default(role.name) }}{% endfor -%})
{% endfor -%}
{% endif -%}
{% if curr_associated or prev_associated -%}
## People
{% if curr_associated -%}
### Currently associated
{% for ass in curr_associated -%}
- [{{ ass.object.given_name }} {{ ass.object.family_name }}](/{{ ass.object.pid|replace('xyzrins:', '') }}) ({% for role in ass.roles %}{{ ', ' if not loop.first }}{{ role.display_label|default(role.name) }}{% endfor -%}){{ (" \n " ~ ass.description).rstrip() }}
{% endfor -%}
{% endif -%}
{% if prev_associated -%}
### Previously associated
{% for ass in prev_associated -%}
- [{{ ass.object.given_name }} {{ ass.object.family_name }}](/{{ ass.object.pid|replace('xyzrins:', '') }}) ({% for role in ass.roles %}{{ ', ' if not loop.first }}{{ role.display_label|default(role.name) }}{% endfor -%} {{ assoc_period(ass, "; ") }}){{ (" \n " ~ ass.description).rstrip() }}
{% endfor -%}
{% endif -%}
{% endif -%}
{% if generated -%}
## Outputs
{% for gen in generated -%}
- [{{ gen.display_label|default(gen.title)|default(gen.name) }}]({{ gen.pid|replace('xyzrins:', '/') }})
{% endfor -%}
{% endif %}
{% endblock %}