Create partialCached variant identifier for page collection

I’m slowly implementing partialCached on many of my projects.

The variant parameter is great, and I would like to use it in conjuncture with a slice of data.
Per exemple, if a post share the same authors, I want to identify this partial with those two authors.
In this case it’s easy:

{{ partialCached "authors.html" . (string (delimit .Params.authors ""))}}

But in order to use the same trick on a page collection, I have to use scratch and don’t find it ideal.

{{ $novels := where (.Site.RegularPages.RelatedIndices . "novel" ) "Type" "roman" }}
{{ range $novels }}
    {{ $.Scratch.Add "novelPartialID" (slice .Params.novel) }}
{{ end }}
{{ $novelPartialID := string (delimit ($.Scratch.Get "novelPartialID") "") }}

The reason behind this .Scratch.Add (slice ..) + delimit hack is Hugo will throw unable to cast []string{"oeuvre"} of type []string to string if I try to use string on a string built with .Scratch.Add.

Anyway, I’M wondering if there is cleaner way to built my partial ID maybe using apply or something else ? I know, partialCached can take any number of variants but then again, how to transform a slice into function arguments…

Thanks a ton!

Turns out you can use printf "%x" to turn anything into a unique base64 string! That’s the perfect way to identify the unicity of a partial if you apply this on a data set used in it (like a collection of authors or pages).

That doesn’t sound right to me.

Oops… Edited.