diff --git a/content/en/functions/duration.md b/content/en/functions/duration.md index 985c6c83f..fa7b13843 100644 --- a/content/en/functions/duration.md +++ b/content/en/functions/duration.md @@ -20,13 +20,17 @@ signature: `time.Duration` converts a given number into a [`time.Duration`](https://pkg.go.dev/time#Duration) structure so you can access its fields. E.g. you can perform [time operations](https://pkg.go.dev/time#Duration) on the returned `time.Duration` value: - {{ printf "There are %.0f seconds in one day." (duration "hour" 24).Seconds }} - +```go-html-template +{{ printf "There are %.0f seconds in one day." (duration "hour" 24).Seconds }} + +``` Make your code simpler to understand by using a [chained pipeline](https://pkg.go.dev/text/template#hdr-Pipelines): - {{ mul 7.75 60 | duration "minute" }} → 7h45m0s - {{ mul 120 60 | mul 1000 | duration "millisecond" }} → 2h0m0s +```go-html-template +{{ mul 7.75 60 | duration "minute" }} → 7h45m0s +{{ mul 120 60 | mul 1000 | duration "millisecond" }} → 2h0m0s +``` You have to specify a time unit for the number given to the function. Valid time units are: diff --git a/content/en/functions/md5.md b/content/en/functions/md5.md index 5b5aba574..dc225bb8c 100644 --- a/content/en/functions/md5.md +++ b/content/en/functions/md5.md @@ -16,7 +16,6 @@ relatedFuncs: signature: - crypto.MD5 INPUT - md5 INPUT - --- ```go-html-template diff --git a/content/en/functions/now.md b/content/en/functions/now.md index 74cadafd5..032fa1026 100644 --- a/content/en/functions/now.md +++ b/content/en/functions/now.md @@ -16,7 +16,6 @@ relatedFuncs: signature: - time.Now - now - --- See [`time.Time`](https://godoc.org/time#Time). diff --git a/content/en/functions/param.md b/content/en/functions/param.md index b7d91544a..92831a63a 100644 --- a/content/en/functions/param.md +++ b/content/en/functions/param.md @@ -10,7 +10,6 @@ namespace: relatedFuncs: [] signature: - .Param KEY - --- The `.Param` method on `.Page` looks for the given `KEY` in page parameters, and returns the corresponding value. If it cannot find the `KEY` in page parameters, it looks for the `KEY` in site parameters. If it cannot find the `KEY` in either location, the `.Param` method returns `nil`. diff --git a/content/en/functions/reflect.IsSlice.md b/content/en/functions/reflect.IsSlice.md index 4eaf40c6b..09a311859 100644 --- a/content/en/functions/reflect.IsSlice.md +++ b/content/en/functions/reflect.IsSlice.md @@ -12,7 +12,6 @@ relatedFuncs: - reflect.IsSlice signature: - reflect.IsSlice INPUT - --- `reflect.IsSlice` reports if `VALUE` is a slice. Returns a boolean. diff --git a/content/en/functions/safeHTML.md b/content/en/functions/safeHTML.md index a80431cb7..025471899 100644 --- a/content/en/functions/safeHTML.md +++ b/content/en/functions/safeHTML.md @@ -16,7 +16,6 @@ relatedFuncs: signature: - safe.HTML INPUT - safeHTML INPUT - --- It should not be used for HTML from a third-party, or HTML with unclosed tags or comments. diff --git a/content/en/functions/strings.Contains.md b/content/en/functions/strings.Contains.md index dc8a35370..d37a6b536 100644 --- a/content/en/functions/strings.Contains.md +++ b/content/en/functions/strings.Contains.md @@ -18,8 +18,11 @@ signature: - strings.Contains STRING SUBSTRING --- - {{ strings.Contains "Hugo" "go" }} → true - +```go-html-template +{{ strings.Contains "Hugo" "go" }} → true +``` The check is case sensitive: - {{ strings.Contains "Hugo" "Go" }} → false +```go-html-template +{{ strings.Contains "Hugo" "Go" }} → false +``` diff --git a/content/en/functions/strings.ContainsAny.md b/content/en/functions/strings.ContainsAny.md index f41ca0ec9..281f6ec7d 100644 --- a/content/en/functions/strings.ContainsAny.md +++ b/content/en/functions/strings.ContainsAny.md @@ -16,11 +16,14 @@ relatedFuncs: - collections.In signature: - strings.ContainsAny STRING CHARACTERS - --- - {{ strings.ContainsAny "Hugo" "gm" }} → true +```go-html-template +{{ strings.ContainsAny "Hugo" "gm" }} → true +--- The check is case sensitive: - {{ strings.ContainsAny "Hugo" "Gm" }} → false +```go-html-template +{{ strings.ContainsAny "Hugo" "Gm" }} → false +``` diff --git a/content/en/functions/strings.TrimLeft.md b/content/en/functions/strings.TrimLeft.md index eb9458b3e..a718e62a3 100644 --- a/content/en/functions/strings.TrimLeft.md +++ b/content/en/functions/strings.TrimLeft.md @@ -16,13 +16,16 @@ relatedFuncs: - strings.TrimSuffix signature: - strings.TrimLeft CUTSET STRING - --- Given the string `"abba"`, leading `"a"`'s can be removed a follows: - {{ strings.TrimLeft "a" "abba" }} → "bba" +```go-html-template +{{ strings.TrimLeft "a" "abba" }} → "bba" +``` Numbers can be handled as well: - {{ strings.TrimLeft 12 1221341221 }} → "341221" +```go-html-template +{{ strings.TrimLeft 12 1221341221 }} → "341221" +``` diff --git a/content/en/functions/strings.TrimPrefix.md b/content/en/functions/strings.TrimPrefix.md index 2103d64c7..661533e55 100644 --- a/content/en/functions/strings.TrimPrefix.md +++ b/content/en/functions/strings.TrimPrefix.md @@ -20,6 +20,8 @@ signature: Given the string `"aabbaa"`, the specified prefix is only removed if `"aabbaa"` starts with it: - {{ strings.TrimPrefix "a" "aabbaa" }} → "abbaa" - {{ strings.TrimPrefix "aa" "aabbaa" }} → "bbaa" - {{ strings.TrimPrefix "aaa" "aabbaa" }} → "aabbaa" +```go-html-template +{{ strings.TrimPrefix "a" "aabbaa" }} → "abbaa" +{{ strings.TrimPrefix "aa" "aabbaa" }} → "bbaa" +{{ strings.TrimPrefix "aaa" "aabbaa" }} → "aabbaa" +``` diff --git a/content/en/functions/strings.TrimRight.md b/content/en/functions/strings.TrimRight.md index 651fbcbca..19c3a6b6d 100644 --- a/content/en/functions/strings.TrimRight.md +++ b/content/en/functions/strings.TrimRight.md @@ -20,8 +20,12 @@ signature: Given the string `"abba"`, trailing `"a"`'s can be removed a follows: - {{ strings.TrimRight "a" "abba" }} → "abb" +```go-html-template +{{ strings.TrimRight "a" "abba" }} → "abb" +``` Numbers can be handled as well: - {{ strings.TrimRight 12 1221341221 }} → "122134" +```go-html-template +{{ strings.TrimRight 12 1221341221 }} → "122134" +``` diff --git a/content/en/functions/strings.TrimSuffix.md b/content/en/functions/strings.TrimSuffix.md index 3fe81d94a..eaf4b1492 100644 --- a/content/en/functions/strings.TrimSuffix.md +++ b/content/en/functions/strings.TrimSuffix.md @@ -20,6 +20,8 @@ signature: Given the string `"aabbaa"`, the specified suffix is only removed if `"aabbaa"` ends with it: - {{ strings.TrimSuffix "a" "aabbaa" }} → "aabba" - {{ strings.TrimSuffix "aa" "aabbaa" }} → "aabb" - {{ strings.TrimSuffix "aaa" "aabbaa" }} → "aabbaa" +```go-html-template +{{ strings.TrimSuffix "a" "aabbaa" }} → "aabba" +{{ strings.TrimSuffix "aa" "aabbaa" }} → "aabb" +{{ strings.TrimSuffix "aaa" "aabbaa" }} → "aabbaa" +``` diff --git a/content/en/functions/templates.Exists.md b/content/en/functions/templates.Exists.md index 0b42d5fdb..1623583b7 100644 --- a/content/en/functions/templates.Exists.md +++ b/content/en/functions/templates.Exists.md @@ -10,7 +10,6 @@ namespace: templates relatedFuncs: [] signature: - templates.Exists PATH - --- A template file is any file living below the `layouts` directories of either the project or any of its theme components including partials and shortcodes. diff --git a/content/en/functions/time.ParseDuration.md b/content/en/functions/time.ParseDuration.md index 146082ce9..e019648e6 100644 --- a/content/en/functions/time.ParseDuration.md +++ b/content/en/functions/time.ParseDuration.md @@ -22,5 +22,7 @@ A duration string is a possibly signed sequence of decimal numbers, each with op You can perform [time operations](https://pkg.go.dev/time#Duration) on the returned `time.Duration` value: - {{ printf "There are %.0f seconds in one day." (time.ParseDuration "24h").Seconds }} - +```go-html-template +{{ printf "There are %.0f seconds in one day." (time.ParseDuration "24h").Seconds }} + +```