mirror of
https://github.com/gohugoio/hugo.git
synced 2025-05-09 04:07:01 +03:00
Merge commit '5be51ac3db
'
This commit is contained in:
commit
653f1c1d46
987 changed files with 12379 additions and 14083 deletions
|
@ -3,17 +3,11 @@ title: strings.Chomp
|
|||
description: Returns the given string, removing all trailing newline characters and carriage returns.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [chomp]
|
||||
related:
|
||||
- functions/strings/Trim
|
||||
- functions/strings/TrimSpace
|
||||
- functions/strings/TrimLeft
|
||||
- functions/strings/TrimPrefix
|
||||
- functions/strings/TrimRight
|
||||
- functions/strings/TrimSuffix
|
||||
returnType: any
|
||||
signatures: [strings.Chomp STRING]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [chomp]
|
||||
returnType: any
|
||||
signatures: [strings.Chomp STRING]
|
||||
aliases: [/functions/chomp]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,16 +3,11 @@ title: strings.Contains
|
|||
description: Reports whether the given string contains the given substring.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/strings/ContainsAny
|
||||
- functions/strings/ContainsNonSpace
|
||||
- functions/strings/HasPrefix
|
||||
- functions/strings/HasSuffix
|
||||
- functions/collections/In
|
||||
returnType: bool
|
||||
signatures: [strings.Contains STRING SUBSTRING]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: bool
|
||||
signatures: [strings.Contains STRING SUBSTRING]
|
||||
aliases: [/functions/strings.contains]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,16 +3,11 @@ title: strings.ContainsAny
|
|||
description: Reports whether the given string contains any character within the given set.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/strings/Contains
|
||||
- functions/strings/ContainsNonSpace
|
||||
- functions/strings/HasPrefix
|
||||
- functions/strings/HasSuffix
|
||||
- functions/collections/In
|
||||
returnType: bool
|
||||
signatures: [strings.ContainsAny STRING SET]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: bool
|
||||
signatures: [strings.ContainsAny STRING SET]
|
||||
aliases: [/functions/strings.containsany]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,16 +3,11 @@ title: strings.ContainsNonSpace
|
|||
description: Reports whether the given string contains any non-space characters as defined by Unicode.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/strings/Contains
|
||||
- functions/strings/ContainsAny
|
||||
- functions/strings/HasPrefix
|
||||
- functions/strings/HasSuffix
|
||||
- functions/collections/In
|
||||
returnType: bool
|
||||
signatures: [strings.ContainsNonSpace STRING]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: bool
|
||||
signatures: [strings.ContainsNonSpace STRING]
|
||||
aliases: [/functions/strings.containsnonspace]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,15 +3,11 @@ title: strings.Count
|
|||
description: Returns the number of non-overlapping instances of the given substring within the given string.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/go-template/len
|
||||
- functions/strings/CountRunes
|
||||
- functions/strings/CountWords
|
||||
- functions/strings/RuneCount
|
||||
returnType: int
|
||||
signatures: [strings.Count SUBSTR STRING]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: int
|
||||
signatures: [strings.Count SUBSTR STRING]
|
||||
aliases: [/functions/strings.count]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,15 +3,11 @@ title: strings.CountRunes
|
|||
description: Returns the number of runes in the given string excluding whitespace.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [countrunes]
|
||||
related:
|
||||
- functions/go-template/len
|
||||
- functions/strings/Count
|
||||
- functions/strings/CountWords
|
||||
- functions/strings/RuneCount
|
||||
returnType: int
|
||||
signatures: [strings.CountRunes INPUT]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [countrunes]
|
||||
returnType: int
|
||||
signatures: [strings.CountRunes INPUT]
|
||||
aliases: [/functions/countrunes]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,15 +3,11 @@ title: strings.CountWords
|
|||
description: Returns the number of words in the given string.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [countwords]
|
||||
related:
|
||||
- functions/go-template/len
|
||||
- functions/strings/Count
|
||||
- functions/strings/CountRunes
|
||||
- functions/strings/RuneCount
|
||||
returnType: int
|
||||
signatures: [strings.CountWords INPUT]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [countwords]
|
||||
returnType: int
|
||||
signatures: [strings.CountWords INPUT]
|
||||
aliases: [/functions/countwords]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@ title: strings.Diff
|
|||
description: Returns an anchored diff of the two texts OLD and NEW in the unified diff format. If OLD and NEW are identical, returns an empty string.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related: []
|
||||
returnType: string
|
||||
signatures: [strings.Diff OLDNAME OLD NEWNAME NEW]
|
||||
params:
|
||||
functions_and_methods:
|
||||
returnType: string
|
||||
signatures: [strings.Diff OLDNAME OLD NEWNAME NEW]
|
||||
---
|
||||
|
||||
{{< new-in 0.125.0 />}}
|
||||
|
|
|
@ -3,20 +3,17 @@ title: strings.FindRESubmatch
|
|||
description: Returns a slice of all successive matches of the regular expression. Each element is a slice of strings holding the text of the leftmost match of the regular expression and the matches, if any, of its subexpressions.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [findRESubmatch]
|
||||
related:
|
||||
- functions/strings/FindRE
|
||||
- functions/strings/Replace
|
||||
- functions/strings/ReplaceRE
|
||||
returnType: '[][]string'
|
||||
signatures: ['strings.FindRESubmatch PATTERN INPUT [LIMIT]']
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [findRESubmatch]
|
||||
returnType: '[][]string'
|
||||
signatures: ['strings.FindRESubmatch PATTERN INPUT [LIMIT]']
|
||||
aliases: [/functions/findresubmatch]
|
||||
---
|
||||
|
||||
By default, `findRESubmatch` finds all matches. You can limit the number of matches with an optional LIMIT argument. A return value of nil indicates no match.
|
||||
|
||||
{{% include "functions/_common/regular-expressions.md" %}}
|
||||
{{% include "/_common/functions/regular-expressions.md" %}}
|
||||
|
||||
## Demonstrative examples
|
||||
|
||||
|
@ -85,6 +82,5 @@ https://example.org
|
|||
https://gohugo.io
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
You can write and test your regular expression using [regex101.com](https://regex101.com/). Be sure to select the Go flavor before you begin.
|
||||
{{% /note %}}
|
||||
> [!note]
|
||||
> You can write and test your regular expression using [regex101.com](https://regex101.com/). Be sure to select the Go flavor before you begin.
|
||||
|
|
|
@ -3,19 +3,16 @@ title: strings.FindRE
|
|||
description: Returns a slice of strings that match the regular expression.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [findRE]
|
||||
related:
|
||||
- functions/strings/FindRESubmatch
|
||||
- functions/strings/Replace
|
||||
- functions/strings/ReplaceRE
|
||||
returnType: '[]string'
|
||||
signatures: ['strings.FindRE PATTERN INPUT [LIMIT]']
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [findRE]
|
||||
returnType: '[]string'
|
||||
signatures: ['strings.FindRE PATTERN INPUT [LIMIT]']
|
||||
aliases: [/functions/findre]
|
||||
---
|
||||
By default, `findRE` finds all matches. You can limit the number of matches with an optional LIMIT argument.
|
||||
|
||||
{{% include "functions/_common/regular-expressions.md" %}}
|
||||
{{% include "/_common/functions/regular-expressions.md" %}}
|
||||
|
||||
This example returns a slice of all second level headings (`h2` elements) within the rendered `.Content`:
|
||||
|
||||
|
@ -31,6 +28,5 @@ To limit the number of matches to one:
|
|||
{{ findRE `(?s)<h2.*?>.*?</h2>` .Content 1 }}
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
You can write and test your regular expression using [regex101.com](https://regex101.com/). Be sure to select the Go flavor before you begin.
|
||||
{{% /note %}}
|
||||
> [!note]
|
||||
> You can write and test your regular expression using [regex101.com](https://regex101.com/). Be sure to select the Go flavor before you begin.
|
||||
|
|
|
@ -3,14 +3,11 @@ title: strings.FirstUpper
|
|||
description: Returns the given string, capitalizing the first character.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/strings/Title
|
||||
- functions/strings/ToLower
|
||||
- functions/strings/ToUpper
|
||||
returnType: string
|
||||
signatures: [strings.FirstUpper STRING]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: string
|
||||
signatures: [strings.FirstUpper STRING]
|
||||
aliases: [/functions/strings.firstupper]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,16 +3,11 @@ title: strings.HasPrefix
|
|||
description: Reports whether the given string begins with the given prefix.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [hasPrefix]
|
||||
related:
|
||||
- functions/strings/Contains
|
||||
- functions/strings/ContainsAny
|
||||
- functions/strings/ContainsNonSpace
|
||||
- functions/strings/HasSuffix
|
||||
- functions/collections/In
|
||||
returnType: bool
|
||||
signatures: [strings.HasPrefix STRING PREFIX]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [hasPrefix]
|
||||
returnType: bool
|
||||
signatures: [strings.HasPrefix STRING PREFIX]
|
||||
aliases: [/functions/hasprefix,/functions/strings.hasprefix]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,16 +3,11 @@ title: strings.HasSuffix
|
|||
description: Reports whether the given string ends with the given suffix.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [hasSuffix]
|
||||
related:
|
||||
- functions/strings/Contains
|
||||
- functions/strings/ContainsAny
|
||||
- functions/strings/ContainsNonSpace
|
||||
- functions/strings/HasPrefix
|
||||
- functions/collections/In
|
||||
returnType: bool
|
||||
signatures: [strings.HasSuffix STRING SUFFIX]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [hasSuffix]
|
||||
returnType: bool
|
||||
signatures: [strings.HasSuffix STRING SUFFIX]
|
||||
aliases: [/functions/hassuffix,/functions/strings/hassuffix]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@ title: strings.Repeat
|
|||
description: Returns a new string consisting of zero or more copies of another string.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related: []
|
||||
returnType: string
|
||||
signatures: [strings.Repeat COUNT INPUT]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: string
|
||||
signatures: [strings.Repeat COUNT INPUT]
|
||||
aliases: [/functions/strings.repeat]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,14 +3,11 @@ title: strings.Replace
|
|||
description: Returns a copy of INPUT, replacing all occurrences of OLD with NEW.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [replace]
|
||||
related:
|
||||
- functions/strings/FindRE
|
||||
- functions/strings/FindRESubmatch
|
||||
- functions/strings/ReplaceRE
|
||||
returnType: string
|
||||
signatures: ['strings.Replace INPUT OLD NEW [LIMIT]']
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [replace]
|
||||
returnType: string
|
||||
signatures: ['strings.Replace INPUT OLD NEW [LIMIT]']
|
||||
aliases: [/functions/replace]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,18 +3,15 @@ title: strings.ReplaceRE
|
|||
description: Returns a copy of INPUT, replacing all occurrences of a regular expression with a replacement pattern.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [replaceRE]
|
||||
related:
|
||||
- functions/strings/FindRE
|
||||
- functions/strings/FindRESubmatch
|
||||
- functions/strings/Replace
|
||||
returnType: string
|
||||
signatures: ['strings.ReplaceRE PATTERN REPLACEMENT INPUT [LIMIT]']
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [replaceRE]
|
||||
returnType: string
|
||||
signatures: ['strings.ReplaceRE PATTERN REPLACEMENT INPUT [LIMIT]']
|
||||
aliases: [/functions/replacere]
|
||||
---
|
||||
|
||||
{{% include "functions/_common/regular-expressions.md" %}}
|
||||
{{% include "/_common/functions/regular-expressions.md" %}}
|
||||
|
||||
```go-html-template
|
||||
{{ $s := "a-b--c---d" }}
|
||||
|
@ -35,9 +32,7 @@ Use `$1`, `$2`, etc. within the replacement string to insert the content of each
|
|||
{{ replaceRE "^https?://([^/]+).*" "$1" $s }} → gohugo.io
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
You can write and test your regular expression using [regex101.com](https://regex101.com/). Be sure to select the Go flavor before you begin.
|
||||
{{% /note %}}
|
||||
> [!note]
|
||||
> You can write and test your regular expression using [regex101.com]. Be sure to select the Go flavor before you begin.
|
||||
|
||||
[RE2]: https://github.com/google/re2/wiki/Syntax
|
||||
[string literal]: https://go.dev/ref/spec#String_literals
|
||||
[regex101.com]: https://regex101.com/
|
||||
|
|
|
@ -3,15 +3,11 @@ title: strings.RuneCount
|
|||
description: Returns the number of runes in the given string.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/go-template/len
|
||||
- functions/strings/Count
|
||||
- functions/strings/CountRunes
|
||||
- functions/strings/CountWords
|
||||
returnType: int
|
||||
signatures: [strings.RuneCount INPUT]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: int
|
||||
signatures: [strings.RuneCount INPUT]
|
||||
aliases: [/functions/strings.runecount]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,12 +3,11 @@ title: strings.SliceString
|
|||
description: Returns a substring of the given string, beginning with the start position and ending before the end position.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [slicestr]
|
||||
related:
|
||||
- functions/strings/Substr
|
||||
returnType: string
|
||||
signatures: ['strings.SliceString STRING [START] [END]']
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [slicestr]
|
||||
returnType: string
|
||||
signatures: ['strings.SliceString STRING [START] [END]']
|
||||
aliases: [/functions/slicestr]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,12 +3,11 @@ title: strings.Split
|
|||
description: Returns a slice of strings by splitting the given string by a delimiter.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [split]
|
||||
related:
|
||||
- functions/collections/Delimit
|
||||
returnType: string
|
||||
signatures: [strings.Split STRING DELIM]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [split]
|
||||
returnType: '[]string'
|
||||
signatures: [strings.Split STRING DELIM]
|
||||
aliases: [/functions/split]
|
||||
---
|
||||
|
||||
|
@ -19,8 +18,7 @@ Examples:
|
|||
{{ split "abc" "" }} → ["a", "b", "c"]
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
The `strings.Split` function essentially does the opposite of the [`collections.Delimit`] function. While `split` creates a slice from a string, `delimit` creates a string from a slice.
|
||||
> [!note]
|
||||
> The `strings.Split` function essentially does the opposite of the [`collections.Delimit`] function. While `split` creates a slice from a string, `delimit` creates a string from a slice.
|
||||
|
||||
[`collections.Delimit`]: /functions/collections/delimit/
|
||||
{{% /note %}}
|
||||
|
|
|
@ -3,16 +3,15 @@ title: strings.Substr
|
|||
description: Returns a substring of the given string, beginning with the start position and ending after the given length.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [substr]
|
||||
related:
|
||||
- functions/strings/SliceString
|
||||
returnType: string
|
||||
signatures: ['strings.Substr STRING [START] [LENGTH]']
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [substr]
|
||||
returnType: string
|
||||
signatures: ['strings.Substr STRING [START] [LENGTH]']
|
||||
aliases: [/functions/substr]
|
||||
---
|
||||
|
||||
The start position is zero-based, where `0` represents the first character of the string. If START is not specified, the substring will begin at position `0`. Specify a negative START position to extract characters from the end of the string.
|
||||
The start position is zero-based, where `0` represents the first character of the string. If START is not specified, the substring will begin at position `0`. Specify a negative START position to extract characters from the end of the string.
|
||||
|
||||
If LENGTH is not specified, the substring will include all characters from the START position to the end of the string. If negative, that number of characters will be omitted from the end of string.
|
||||
|
||||
|
|
|
@ -3,14 +3,11 @@ title: strings.Title
|
|||
description: Returns the given string, converting it to title case.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [title]
|
||||
related:
|
||||
- functions/strings/FirstUpper
|
||||
- functions/strings/ToLower
|
||||
- functions/strings/ToUpper
|
||||
returnType: string
|
||||
signatures: [strings.Title STRING]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [title]
|
||||
returnType: string
|
||||
signatures: [strings.Title STRING]
|
||||
aliases: [/functions/title]
|
||||
---
|
||||
|
||||
|
@ -29,4 +26,4 @@ The last option is useful if your theme uses the `title` function, and you would
|
|||
|
||||
[Associated Press Stylebook]: https://www.apstylebook.com/
|
||||
[Chicago Manual of Style]: https://www.chicagomanualofstyle.org/home.html
|
||||
[site configuration]: /getting-started/configuration/#configure-title-case
|
||||
[site configuration]: /configuration/all/#title-case-style
|
||||
|
|
|
@ -3,14 +3,11 @@ title: strings.ToLower
|
|||
description: Returns the given string, converting all characters to lowercase.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [lower]
|
||||
related:
|
||||
- functions/strings/FirstUpper
|
||||
- functions/strings/Title
|
||||
- functions/strings/ToUpper
|
||||
returnType: string
|
||||
signatures: [strings.ToLower INPUT]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [lower]
|
||||
returnType: string
|
||||
signatures: [strings.ToLower INPUT]
|
||||
aliases: [/functions/lower]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,14 +3,11 @@ title: strings.ToUpper
|
|||
description: Returns the given string, converting all characters to uppercase.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [upper]
|
||||
related:
|
||||
- functions/strings/FirstUpper
|
||||
- functions/strings/Title
|
||||
- functions/strings/ToLower
|
||||
returnType: string
|
||||
signatures: [strings.ToUpper INPUT]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [upper]
|
||||
returnType: string
|
||||
signatures: [strings.ToUpper INPUT]
|
||||
aliases: [/functions/upper]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,17 +3,11 @@ title: strings.Trim
|
|||
description: Returns the given string, removing leading and trailing characters specified in the cutset.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [trim]
|
||||
related:
|
||||
- functions/strings/Chomp
|
||||
- functions/strings/TrimSpace
|
||||
- functions/strings/TrimLeft
|
||||
- functions/strings/TrimPrefix
|
||||
- functions/strings/TrimRight
|
||||
- functions/strings/TrimSuffix
|
||||
returnType: string
|
||||
signatures: [strings.Trim INPUT CUTSET]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [trim]
|
||||
returnType: string
|
||||
signatures: [strings.Trim INPUT CUTSET]
|
||||
aliases: [/functions/trim]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,17 +3,11 @@ title: strings.TrimLeft
|
|||
description: Returns the given string, removing leading characters specified in the cutset.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/strings/Chomp
|
||||
- functions/strings/Trim
|
||||
- functions/strings/TrimSpace
|
||||
- functions/strings/TrimPrefix
|
||||
- functions/strings/TrimRight
|
||||
- functions/strings/TrimSuffix
|
||||
returnType: string
|
||||
signatures: [strings.TrimLeft CUTSET STRING]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: string
|
||||
signatures: [strings.TrimLeft CUTSET STRING]
|
||||
aliases: [/functions/strings.trimleft]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,17 +3,11 @@ title: strings.TrimPrefix
|
|||
description: Returns the given string, removing the prefix from the beginning of the string.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/strings/Chomp
|
||||
- functions/strings/Trim
|
||||
- functions/strings/TrimSpace
|
||||
- functions/strings/TrimLeft
|
||||
- functions/strings/TrimRight
|
||||
- functions/strings/TrimSuffix
|
||||
returnType: string
|
||||
signatures: [strings.TrimPrefix PREFIX STRING]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: string
|
||||
signatures: [strings.TrimPrefix PREFIX STRING]
|
||||
aliases: [/functions/strings.trimprefix]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,17 +3,11 @@ title: strings.TrimRight
|
|||
description: Returns the given string, removing trailing characters specified in the cutset.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/strings/Chomp
|
||||
- functions/strings/Trim
|
||||
- functions/strings/TrimSpace
|
||||
- functions/strings/TrimLeft
|
||||
- functions/strings/TrimPrefix
|
||||
- functions/strings/TrimSuffix
|
||||
returnType: string
|
||||
signatures: [strings.TrimRight CUTSET STRING]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: string
|
||||
signatures: [strings.TrimRight CUTSET STRING]
|
||||
aliases: [/functions/strings.trimright]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,16 +3,10 @@ title: strings.TrimSpace
|
|||
description: Returns the given string, removing leading and trailing whitespace as defined by Unicode.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- functions/strings/Chomp
|
||||
- functions/strings/Trim
|
||||
- functions/strings/TrimLeft
|
||||
- functions/strings/TrimPrefix
|
||||
- functions/strings/TrimRight
|
||||
- functions/strings/TrimSuffix
|
||||
returnType: string
|
||||
signatures: [strings.TrimSpace INPUT]
|
||||
params:
|
||||
functions_and_methods:
|
||||
returnType: string
|
||||
signatures: [strings.TrimSpace INPUT]
|
||||
---
|
||||
|
||||
{{< new-in 0.136.3 />}}
|
||||
|
|
|
@ -3,17 +3,11 @@ title: strings.TrimSuffix
|
|||
description: Returns the given string, removing the suffix from the end of the string.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/strings/Chomp
|
||||
- functions/strings/Trim
|
||||
- functions/strings/TrimSpace
|
||||
- functions/strings/TrimLeft
|
||||
- functions/strings/TrimPrefix
|
||||
- functions/strings/TrimRight
|
||||
returnType: string
|
||||
signatures: [strings.TrimSuffix SUFFIX STRING]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
returnType: string
|
||||
signatures: [strings.TrimSuffix SUFFIX STRING]
|
||||
aliases: [/functions/strings.trimsuffix]
|
||||
---
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@ title: strings.Truncate
|
|||
description: Returns the given string, truncating it to a maximum length without cutting words or leaving unclosed HTML tags.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [truncate]
|
||||
related: []
|
||||
returnType: template.HTML
|
||||
signatures: ['strings.Truncate SIZE [ELLIPSIS] INPUT']
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [truncate]
|
||||
returnType: template.HTML
|
||||
signatures: ['strings.Truncate SIZE [ELLIPSIS] INPUT']
|
||||
aliases: [/functions/truncate]
|
||||
---
|
||||
|
||||
|
@ -17,8 +17,7 @@ Since Go templates are HTML-aware, `truncate` will intelligently handle normal s
|
|||
{{ "<em>Keep my HTML</em>" | safeHTML | truncate 10 }} → <em>Keep my …</em>
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
If you have a raw string that contains HTML tags you want to remain treated as HTML, you will need to convert the string to HTML using the [`safeHTML`]function before sending the value to `truncate`. Otherwise, the HTML tags will be escaped when passed through the `truncate` function.
|
||||
> [!note]
|
||||
> If you have a raw string that contains HTML tags you want to remain treated as HTML, you will need to convert the string to HTML using the [`safeHTML`]function before sending the value to `truncate`. Otherwise, the HTML tags will be escaped when passed through the `truncate` function.
|
||||
|
||||
[`safeHTML`]: /functions/safe/html/
|
||||
{{% /note %}}
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
---
|
||||
title: String functions
|
||||
linkTitle: strings
|
||||
description: Template functions to work with strings.
|
||||
description: Use these functions to work with strings.
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: functions
|
||||
---
|
||||
|
||||
Use these functions to work with strings.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue