tpl/partials: Allow any key type in partialCached

Fixes #6572
This commit is contained in:
Bjørn Erik Pedersen
2019-12-02 21:10:27 +01:00
parent 40a092b068
commit 0efb00c2a8
9 changed files with 160 additions and 55 deletions

View File

@@ -13,11 +13,7 @@
package internal
import (
"strconv"
"github.com/mitchellh/hashstructure"
)
import "github.com/gohugoio/hugo/helpers"
// ResourceTransformationKey are provided by the different transformation implementations.
// It identifies the transformation (name) and its configuration (elements).
@@ -42,23 +38,6 @@ func (k ResourceTransformationKey) Value() string {
return k.Name
}
return k.Name + "_" + HashString(k.elements...)
return k.Name + "_" + helpers.HashString(k.elements...)
}
// HashString returns a hash from the given elements.
// It will panic if the hash cannot be calculated.
func HashString(elements ...interface{}) string {
var o interface{}
if len(elements) == 1 {
o = elements[0]
} else {
o = elements
}
hash, err := hashstructure.Hash(o, nil)
if err != nil {
panic(err)
}
return strconv.FormatUint(hash, 10)
}