Debian Codegraph @

docs/content/en/functions/fmt/Warnidf.md

raw
1 ---
2 title: fmt.Warnidf
3 description: Logs a suppressible WARNING from a template.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 aliases: [warnidf]
9 returnType: string
10 signatures: ['fmt.Warnidf ID FORMAT [INPUT]']
11 aliases: [/functions/warnidf]
12 ---
13
14 {{% include "/_common/functions/fmt/format-string.md" %}}
15
16 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 project configuration.
17
18 This template code:
19
20 ```go-html-template
21 {{ warnidf "warning-42" "You should consider fixing this." }}
22 ```
23
24 Produces this console log:
25
26 ```text
27 WARN You should consider fixing this.
28 You can suppress this warning by adding the following to your project configuration:
29 ignoreLogs = ['warning-42']
30 ```
31
32 To suppress this message:
33
34 {{< code-toggle file=hugo >}}
35 ignoreLogs = ["warning-42"]
36 {{< /code-toggle >}}
37
38 [`warnf`]: /functions/fmt/warnf/