mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
Merge commit '8b9803425e63e1b1801f8d5d676e96368d706722'
This commit is contained in:
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/
|
Reference in New Issue
Block a user