mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-28 23:32:11 -05:00
parent
62d031aedf
commit
be58c7b9c8
2 changed files with 13 additions and 0 deletions
|
@ -18,6 +18,7 @@ import (
|
||||||
"encoding/csv"
|
"encoding/csv"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gohugoio/hugo/common/herrors"
|
"github.com/gohugoio/hugo/common/herrors"
|
||||||
|
|
||||||
|
@ -39,6 +40,14 @@ type Decoder struct {
|
||||||
Comment rune
|
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.
|
// Default is a Decoder in its default configuration.
|
||||||
var Default = Decoder{
|
var Default = Decoder{
|
||||||
Delimiter: ',',
|
Delimiter: ',',
|
||||||
|
|
|
@ -62,6 +62,10 @@ func (ns *Namespace) Unmarshal(args ...interface{}) (interface{}, error) {
|
||||||
return nil, errors.New("no Key set in Resource")
|
return nil, errors.New("no Key set in Resource")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if decoder != metadecoders.Default {
|
||||||
|
key += decoder.OptionsKey()
|
||||||
|
}
|
||||||
|
|
||||||
return ns.cache.GetOrCreate(key, func() (interface{}, error) {
|
return ns.cache.GetOrCreate(key, func() (interface{}, error) {
|
||||||
f := metadecoders.FormatFromMediaType(r.MediaType())
|
f := metadecoders.FormatFromMediaType(r.MediaType())
|
||||||
if f == "" {
|
if f == "" {
|
||||||
|
|
Loading…
Reference in a new issue