tpl: Update Hugo time to support optional [LOCATION] parameter

This commit is contained in:
Mark Johnson
2020-10-19 15:58:05 -07:00
committed by Bjørn Erik Pedersen
parent b886fa46bb
commit 26eeb29147
4 changed files with 132 additions and 11 deletions

View File

@@ -34,15 +34,26 @@ func init() {
//
// If args are passed, call AsTime().
if len(args) == 0 {
switch len(args) {
case 0:
return ctx
}
case 1:
t, err := ctx.AsTime(args[0])
if err != nil {
return err
}
return t
case 2:
t, err := ctx.AsTime(args[0], args[1])
if err != nil {
return err
}
return t
t, err := ctx.AsTime(args[0])
if err != nil {
return err
// 3 or more arguments. Currently not supported.
default:
return "Invalid arguments supplied to `time`. Refer to time documentation: https://gohugo.io/functions/time/"
}
return t
},
}