diff --git a/content/en/functions/crypto.FNV32a.md b/content/en/functions/crypto.FNV32a.md new file mode 100644 index 000000000..dddf7a9aa --- /dev/null +++ b/content/en/functions/crypto.FNV32a.md @@ -0,0 +1,15 @@ +--- +title: crypto.FNV32a +description: Returns the FNV (Fowler–Noll–Vo) 32 bit hash of a given string. +categories: [functions] +menu: + docs: + parent: "functions" +keywords: [crypto hash FNV32 Fowler-Noll-Vo] +signature: ["crypto.FNV32a STRING"] +aliases: [] +--- + +This function calculates the 32 bit [FNV1a hash](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#FNV-1a_hash) of a given string according to the [specification](https://datatracker.ietf.org/doc/html/draft-eastlake-fnv-12): + + {{ crypto.FNV32a "Hello world" }} → 1498229191 diff --git a/content/en/functions/duration.md b/content/en/functions/duration.md new file mode 100644 index 000000000..bf771c0a9 --- /dev/null +++ b/content/en/functions/duration.md @@ -0,0 +1,32 @@ +--- +title: duration +description: Returns a `time.Duration` structure, using the given time unit and duration number. +categories: [functions] +menu: + docs: + parent: "functions" +keywords: [time duration] +signature: ["duration TIME_UNIT DURATION_NUMBER"] +aliases: [] +--- + +`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 }} + + +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 + +You have to specify a time unit for the number given to the function. Valid time units are: + +Duration|Valid time units +:--|:-- +hours|`hour`, `h` +minutes|`minute`, `m` +seconds|`second`, `s` +milliseconds|`millisecond`, `ms` +microseconds|`microsecond`, `us`, `µs` +nanoseconds|`nanosecond`, `ns` diff --git a/content/en/functions/lower.md b/content/en/functions/lower.md index 0e8ba6c6d..3fbfc919b 100644 --- a/content/en/functions/lower.md +++ b/content/en/functions/lower.md @@ -10,7 +10,9 @@ menu: docs: parent: "functions" keywords: [strings,casing] -signature: ["lower INPUT"] +signature: + - "lower INPUT" + - "strings.ToLower INPUT" workson: [] hugoversion: relatedfuncs: [] @@ -18,6 +20,10 @@ deprecated: false aliases: [] --- -``` -{{lower "BatMan"}} → "batman" + +Note that `lower` can be applied in your templates in more than one way: + +```go-html-template +{{ lower "BatMan" }} → "batman" +{{ "BatMan" | lower }} → "batman" ``` diff --git a/content/en/functions/strings.Contains.md b/content/en/functions/strings.Contains.md new file mode 100644 index 000000000..8ebd9ad33 --- /dev/null +++ b/content/en/functions/strings.Contains.md @@ -0,0 +1,18 @@ +--- +title: strings.Contains +description: Reports whether a string contains a substring. +categories: [functions] +menu: + docs: + parent: "functions" +keywords: [string strings substring contains] +signature: ["strings.Contains STRING SUBSTRING"] +aliases: [] +relatedfuncs: [strings.ContainsAny] +--- + + {{ strings.Contains "Hugo" "go" }} → true + +The check is case sensitive: + + {{ strings.Contains "Hugo" "Go" }} → false diff --git a/content/en/functions/strings.ContainsAny.md b/content/en/functions/strings.ContainsAny.md new file mode 100644 index 000000000..bfbc2242b --- /dev/null +++ b/content/en/functions/strings.ContainsAny.md @@ -0,0 +1,18 @@ +--- +title: strings.ContainsAny +description: Reports whether a string contains any character from a given string. +categories: [functions] +menu: + docs: + parent: "functions" +keywords: [string strings substring contains any] +signature: ["strings.ContainsAny STRING CHARACTERS"] +aliases: [] +relatedfuncs: [strings.Contains] +--- + + {{ strings.ContainsAny "Hugo" "gm" }} → true + +The check is case sensitive: + + {{ strings.ContainsAny "Hugo" "Gm" }} → false diff --git a/content/en/functions/time.ParseDuration.md b/content/en/functions/time.ParseDuration.md new file mode 100644 index 000000000..aabba601a --- /dev/null +++ b/content/en/functions/time.ParseDuration.md @@ -0,0 +1,20 @@ +--- +title: time.ParseDuration +description: Parses a given duration string into a `time.Duration` structure. +categories: [functions] +menu: + docs: + parent: "functions" +keywords: [time parse duration] +signature: ["time.ParseDuration DURATION"] +hugoversion: +aliases: [] +--- + +`time.ParseDuration` parses a duration string into a [`time.Duration`](https://pkg.go.dev/time#Duration) structure so you can access its fields. +A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as `300ms`, `-1.5h` or `2h45m`. Valid time units are `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. + +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 }} + diff --git a/content/en/functions/upper.md b/content/en/functions/upper.md index c7d523217..02f4cd578 100644 --- a/content/en/functions/upper.md +++ b/content/en/functions/upper.md @@ -11,7 +11,9 @@ menu: docs: parent: "functions" toc: -signature: ["upper INPUT"] +signature: + - "upper INPUT" + - "strings.ToUpper INPUT" workson: [] hugoversion: relatedfuncs: []