mirror of
https://github.com/gohugoio/hugo.git
synced 2025-05-07 11:16:26 +03:00
Merge commit '8b9803425e
'
This commit is contained in:
commit
af0cb57aaf
475 changed files with 7408 additions and 4720 deletions
|
@ -8,6 +8,7 @@ action:
|
|||
related:
|
||||
- functions/fmt/Erroridf
|
||||
- functions/fmt/Warnf
|
||||
- functions/fmt/Warnidf
|
||||
returnType: string
|
||||
signatures: ['fmt.Errorf FORMAT [INPUT]']
|
||||
aliases: [/functions/errorf]
|
||||
|
@ -18,9 +19,9 @@ aliases: [/functions/errorf]
|
|||
The `errorf` function evaluates the format string, then prints the result to the ERROR log and fails the build.
|
||||
|
||||
```go-html-template
|
||||
{{ errorf "The %q shortcode requires a src parameter. See %s" .Name .Position }}
|
||||
{{ errorf "The %q shortcode requires a src argument. See %s" .Name .Position }}
|
||||
```
|
||||
|
||||
Use the [`erroridf`] function to allow optional suppression of specific errors.
|
||||
|
||||
[`erroridf`]: /functions/fmt/erroridf
|
||||
[`erroridf`]: /functions/fmt/erroridf/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
title: fmt.Erroridf
|
||||
description: Log a suppressable ERROR from a template.
|
||||
description: Log a suppressible ERROR from a template.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
|
@ -8,6 +8,7 @@ action:
|
|||
related:
|
||||
- functions/fmt/Errorf
|
||||
- functions/fmt/Warnf
|
||||
- functions/fmt/Warnidf
|
||||
returnType: string
|
||||
signatures: ['fmt.Erroridf ID FORMAT [INPUT]']
|
||||
aliases: [/functions/erroridf]
|
||||
|
@ -15,7 +16,7 @@ aliases: [/functions/erroridf]
|
|||
|
||||
{{% include "functions/fmt/_common/fmt-layout.md" %}}
|
||||
|
||||
The `erroridf` function evaluates the format string, then prints the result to the ERROR log and fails the build. Unlike the [`errorf`] function, you may suppress errors logged by the `erroridf` function by adding the message ID to the `ignoreErrors` array in your site configuration.
|
||||
The `erroridf` function evaluates the format string, then prints the result to the ERROR log and fails the build. Unlike the [`errorf`] function, you may suppress errors logged by the `erroridf` function by adding the message ID to the `ignoreLogs` array in your site configuration.
|
||||
|
||||
This template code:
|
||||
|
||||
|
@ -28,13 +29,13 @@ Produces this console log:
|
|||
```text
|
||||
ERROR You should consider fixing this.
|
||||
You can suppress this error by adding the following to your site configuration:
|
||||
ignoreErrors = ['error-42']
|
||||
ignoreLogs = ['error-42']
|
||||
```
|
||||
|
||||
To suppress this message:
|
||||
|
||||
{{< code-toggle file=hugo >}}
|
||||
ignoreErrors = ["error-42"]
|
||||
ignoreLogs = ["error-42"]
|
||||
{{< /code-toggle >}}
|
||||
|
||||
[`errorf`]: /functions/fmt/errorf
|
||||
[`errorf`]: /functions/fmt/errorf/
|
||||
|
|
|
@ -8,6 +8,7 @@ action:
|
|||
related:
|
||||
- functions/fmt/Errorf
|
||||
- functions/fmt/Erroridf
|
||||
- functions/fmt/Warnidf
|
||||
returnType: string
|
||||
signatures: ['fmt.Warnf FORMAT [INPUT]']
|
||||
aliases: [/functions/warnf]
|
||||
|
@ -21,6 +22,8 @@ The `warnf` function evaluates the format string, then prints the result to the
|
|||
{{ warnf "The %q shortcode was unable to find %s. See %s" .Name $file .Position }}
|
||||
```
|
||||
|
||||
Use the [`warnidf`] function to allow optional suppression of specific warnings.
|
||||
|
||||
To prevent suppression of duplicate messages when using `warnf` for debugging, make each message unique with the [`math.Counter`] function. For example:
|
||||
|
||||
|
||||
|
@ -30,4 +33,6 @@ To prevent suppression of duplicate messages when using `warnf` for debugging, m
|
|||
{{ end }}
|
||||
```
|
||||
|
||||
[`math.Counter`]: /functions/math/counter
|
||||
[`math.Counter`]: /functions/math/counter/
|
||||
|
||||
[`warnidf`]: /functions/fmt/warnidf/
|
||||
|
|
43
docs/content/en/functions/fmt/Warnidf.md
Normal file
43
docs/content/en/functions/fmt/Warnidf.md
Normal file
|
@ -0,0 +1,43 @@
|
|||
---
|
||||
title: fmt.Warnidf
|
||||
description: Log a suppressible WARNING from a template.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [warnidf]
|
||||
related:
|
||||
- functions/fmt/Errorf
|
||||
- functions/fmt/Erroridf
|
||||
- functions/fmt/Warnf
|
||||
returnType: string
|
||||
signatures: ['fmt.Warnidf ID FORMAT [INPUT]']
|
||||
aliases: [/functions/warnidf]
|
||||
---
|
||||
|
||||
{{< new-in 0.123.0 >}}
|
||||
|
||||
{{% include "functions/fmt/_common/fmt-layout.md" %}}
|
||||
|
||||
The `warnidf` function evaluates the format string, then prints the result to the WARNING log. Unlike the [`warnf`] function, you may suppress warnings logged by the `warnidf` function by adding the message ID to the `ignoreLogs` array in your site configuration.
|
||||
|
||||
This template code:
|
||||
|
||||
```go-html-template
|
||||
{{ warnidf "warning-42" "You should consider fixing this." }}
|
||||
```
|
||||
|
||||
Produces this console log:
|
||||
|
||||
```text
|
||||
WARN You should consider fixing this.
|
||||
You can suppress this warning by adding the following to your site configuration:
|
||||
ignoreLogs = ['warning-42']
|
||||
```
|
||||
|
||||
To suppress this message:
|
||||
|
||||
{{< code-toggle file=hugo >}}
|
||||
ignoreLogs = ["warning-42"]
|
||||
{{< /code-toggle >}}
|
||||
|
||||
[`warnf`]: /functions/fmt/warnf/
|
|
@ -7,7 +7,7 @@ cascade:
|
|||
---
|
||||
|
||||
<!--
|
||||
Files within this headless branch bundle are markdown snippets. Each file must contain front matter delimiters, though front matter fields are not required.
|
||||
Files within this headless branch bundle are Markdown snippets. Each file must contain front matter delimiters, though front matter fields are not required.
|
||||
|
||||
Include the rendered content using the "include" shortcode.
|
||||
-->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue