From 1678ec077ed98235d01cf6c43746d31fa4a757c6 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Sun, 6 Feb 2022 21:30:25 +0300 Subject: [PATCH] site/layouts: add cluster to partialCached key When we cache the output of partials we get duplicate elements be- cause both ISEAL and FSC have "Scope", "Certificate", etc modules. We need to use the cluster as an extra key for the partial cache so these don't overlap. See: https://gohugo.io/functions/partialcached/ --- site/layouts/_default/fsc.html | 5 +++-- site/layouts/_default/home.html | 20 ++++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/site/layouts/_default/fsc.html b/site/layouts/_default/fsc.html index 642c4ea9..c01b78f5 100644 --- a/site/layouts/_default/fsc.html +++ b/site/layouts/_default/fsc.html @@ -33,12 +33,13 @@ {{/* it in the range below. */}} {{ $context := . }} - {{ .Scratch.Set "cluster" "Fsc" }} + {{ $cluster := "Fsc" }} + {{ .Scratch.Set "cluster" $cluster }} {{ $modules := slice "Assurance" "Certificate" "Coverage" "Evaluation" "Form" "Scope" "Status" }} {{ range $modules }} {{ $module := . }} {{ $.Scratch.Set "module" $module }} - {{ partialCached "module-elements.html" $context $module }} + {{ partialCached "module-elements.html" $context $cluster $module }} {{ end }}

Download

diff --git a/site/layouts/_default/home.html b/site/layouts/_default/home.html index 7b68e830..90990c7e 100644 --- a/site/layouts/_default/home.html +++ b/site/layouts/_default/home.html @@ -90,32 +90,40 @@

Global Cluster

- {{ .Scratch.Set "cluster" "Global" }} + {{ $cluster := "Global" }} + {{ .Scratch.Set "cluster" $cluster }} {{ $modules := slice "Coverage" "Form" "Provenance" "Scope" "Status" }} {{ range $modules }} {{ $module := . }} {{ $.Scratch.Set "module" $module }} - {{ partialCached "module-elements.html" $context $module }} + + {{/* Call the partial template to render the module's elements. */}} + {{/* Note that we need to use the $cluster and the $module as */}} + {{/* keys to the partial's cache so the cache is unique (so we */}} + {{/* don't get FSC elements in the ISEAL layout). */}} + {{ partialCached "module-elements.html" $context $cluster $module }} {{ end }}

Certification Cluster

- {{ .Scratch.Set "cluster" "Certification" }} + {{ $cluster := "Certification" }} + {{ .Scratch.Set "cluster" $cluster }} {{ $modules := slice "Certificate" "Certificate Holder, Owner or Certified organization" "Certified Resource or Site" "Certifying Body" }} {{ range $modules }} {{ $module := . }} {{ $.Scratch.Set "module" $module }} - {{ partialCached "module-elements.html" $context $module }} + {{ partialCached "module-elements.html" $context $cluster $module }} {{ end }}

Impact Cluster

- {{ .Scratch.Set "cluster" "Impact" }} + {{ $cluster := "Impact" }} + {{ .Scratch.Set "cluster" $cluster }} {{ $modules := slice "Evaluation" }} {{ range $modules }} {{ $module := . }} {{ $.Scratch.Set "module" $module }} - {{ partialCached "module-elements.html" $context $module }} + {{ partialCached "module-elements.html" $context $cluster $module }} {{ end }}

Download