aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--parser/metadecoders/decoder.go9
-rw-r--r--tpl/transform/unmarshal.go4
2 files changed, 13 insertions, 0 deletions
diff --git a/parser/metadecoders/decoder.go b/parser/metadecoders/decoder.go
index 2f3c27d45..b2d8307b6 100644
--- a/parser/metadecoders/decoder.go
+++ b/parser/metadecoders/decoder.go
@@ -18,6 +18,7 @@ import (
"encoding/csv"
"encoding/json"
"fmt"
+ "strings"
"github.com/gohugoio/hugo/common/herrors"
@@ -39,6 +40,14 @@ type Decoder struct {
Comment rune
}
+// OptionsKey is used in cache keys.
+func (d Decoder) OptionsKey() string {
+ var sb strings.Builder
+ sb.WriteRune(d.Delimiter)
+ sb.WriteRune(d.Comment)
+ return sb.String()
+}
+
// Default is a Decoder in its default configuration.
var Default = Decoder{
Delimiter: ',',
diff --git a/tpl/transform/unmarshal.go b/tpl/transform/unmarshal.go
index bc8386975..c27a21a9e 100644
--- a/tpl/transform/unmarshal.go
+++ b/tpl/transform/unmarshal.go
@@ -62,6 +62,10 @@ func (ns *Namespace) Unmarshal(args ...interface{}) (interface{}, error) {
return nil, errors.New("no Key set in Resource")
}
+ if decoder != metadecoders.Default {
+ key += decoder.OptionsKey()
+ }
+
return ns.cache.GetOrCreate(key, func() (interface{}, error) {
f := metadecoders.FormatFromMediaType(r.MediaType())
if f == "" {