mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
parent
d7f364c27e
commit
70544f9e62
2 changed files with 13 additions and 0 deletions
|
@ -1380,6 +1380,16 @@ func replaceRE(pattern, repl, src interface{}) (_ string, err error) {
|
||||||
return re.ReplaceAllString(srcStr, replStr), nil
|
return re.ReplaceAllString(srcStr, replStr), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// asTime converts the textual representation of the datetime string into
|
||||||
|
// a time.Time interface.
|
||||||
|
func asTime(v interface{}) (interface{}, error) {
|
||||||
|
t, err := cast.ToTimeE(v)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return t, nil
|
||||||
|
}
|
||||||
|
|
||||||
// dateFormat converts the textual representation of the datetime string into
|
// dateFormat converts the textual representation of the datetime string into
|
||||||
// the other form or returns it of the time.Time value. These are formatted
|
// the other form or returns it of the time.Time value. These are formatted
|
||||||
// with the layout string
|
// with the layout string
|
||||||
|
@ -1869,6 +1879,7 @@ func init() {
|
||||||
"sub": func(a, b interface{}) (interface{}, error) { return helpers.DoArithmetic(a, b, '-') },
|
"sub": func(a, b interface{}) (interface{}, error) { return helpers.DoArithmetic(a, b, '-') },
|
||||||
"substr": substr,
|
"substr": substr,
|
||||||
"title": func(a string) string { return strings.Title(a) },
|
"title": func(a string) string { return strings.Title(a) },
|
||||||
|
"time": asTime,
|
||||||
"trim": trim,
|
"trim": trim,
|
||||||
"upper": func(a string) string { return strings.ToUpper(a) },
|
"upper": func(a string) string { return strings.ToUpper(a) },
|
||||||
"urlize": helpers.URLize,
|
"urlize": helpers.URLize,
|
||||||
|
|
|
@ -136,6 +136,7 @@ sub: {{sub 3 2}}
|
||||||
substr: {{substr "BatMan" 0 -3}}
|
substr: {{substr "BatMan" 0 -3}}
|
||||||
substr: {{substr "BatMan" 3 3}}
|
substr: {{substr "BatMan" 3 3}}
|
||||||
title: {{title "Bat man"}}
|
title: {{title "Bat man"}}
|
||||||
|
time: {{ time "2015-01-21" }}
|
||||||
trim: {{ trim "++Batman--" "+-" }}
|
trim: {{ trim "++Batman--" "+-" }}
|
||||||
upper: {{upper "BatMan"}}
|
upper: {{upper "BatMan"}}
|
||||||
urlize: {{ "Bat Man" | urlize }}
|
urlize: {{ "Bat Man" | urlize }}
|
||||||
|
@ -199,6 +200,7 @@ sub: 1
|
||||||
substr: Bat
|
substr: Bat
|
||||||
substr: Man
|
substr: Man
|
||||||
title: Bat Man
|
title: Bat Man
|
||||||
|
time: 2015-01-21T00:00:00Z
|
||||||
trim: Batman
|
trim: Batman
|
||||||
upper: BATMAN
|
upper: BATMAN
|
||||||
urlize: bat-man
|
urlize: bat-man
|
||||||
|
|
Loading…
Reference in a new issue