{{/* Renders one change-history entry as a full German sentence, per the pattern " von wurde(n) in Zeilen am durch geändert. Änderungen in Git anzeigen." (or " wurde in Zeilen am durch angelegt. ..." for a creation entry). Called with a dict: eintrag - one entry from hugo.Data.methoden/varianten's "verlauf" array (datum/autor/hash/zeilen/typ/felder), optionally with an extra "variante" key (the variant's untertitel) when merged in from a variant into a method's aggregated history, see aenderungshistorie.html. titelHTML - pre-rendered link HTML to the method/variant ("Titel"), or "" when this is rendered directly on the entity's own page (no need to name the subject there, see aenderungshistorie.html). Everything below is plain auto-escaped template markup (Hugo/Go's html/template escapes {{ .autor }} etc. on its own, context-aware even inside the git-link href) - titelHTML is the ONE deliberately pre-built HTML fragment, so it's also the only value that needs an explicit "safeHTML" at its single point of use, instead of assembling the whole sentence as a Go string and blanket-marking it safe (previous version - meant every future field added here had to remember to escape itself by hand, with nothing enforcing that). Prints directly (no "return") - callers just place {{ partial "aenderungssatz.html" ... }} where the sentence should appear, see aenderungshistorie.html and layouts/aenderungen/list.html. */}} {{ $eintrag := .eintrag }} {{ $titelHTML := .titelHTML | default "" }} {{/* Labels from hugo/data/feldkatalog.json (generated by scripts/generate-config.sh from admin/config.template.yml's own field labels, see ableger/website#2) instead of a separate hardcoded dict here - "or ... ." falls back to the raw field name for "inhalt" (the one pseudo-field not present in the CMS config, added explicitly to that generated file) and for any future field this partial doesn't know about yet. */}} {{ $felderLesbar := slice }} {{ range $eintrag.felder }}{{ $felderLesbar = $felderLesbar | append (or (index hugo.Data.feldkatalog .) .) }}{{ end }} {{ $liste := delimit $felderLesbar ", " }} {{ $verb := "wurden" }} {{ if eq (len $eintrag.felder) 1 }}{{ $verb = "wurde" }}{{ end }} {{ $datum := $eintrag.datum | time.AsTime | dateFormat "02.01.2006" }} {{ $zeilenText := "" }} {{ with $eintrag.zeilen | int }} {{ if gt . 0 }}{{ $zeilenText = printf "in %d %s " . (cond (eq . 1) "Zeile" "Zeilen") }}{{ end }} {{ end }} {{ $gitLink := "" }} {{ with site.Params.methoden_repo_url }}{{ $gitLink = printf "%s/commit/%s" . $eintrag.hash }}{{ end }} {{ if eq $eintrag.typ "erstellt" -}} {{ if eq $titelHTML "" }}Seite{{ else }}{{ $titelHTML | safeHTML }}{{ end }} wurde {{ $zeilenText }}am {{ $datum }} durch {{ $eintrag.autor }} angelegt{{ with $eintrag.variante }} (Variante „{{ . }}“){{ end }}. {{- else -}} {{ $liste }}{{ if ne $titelHTML "" }} von {{ $titelHTML | safeHTML }}{{ end }} {{ $verb }} {{ $zeilenText }}am {{ $datum }} durch {{ $eintrag.autor }} geändert{{ with $eintrag.variante }} (Variante „{{ . }}“){{ end }}. {{- end }} {{- with $gitLink }} Änderungen in Git anzeigen{{ end }}