mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-09 07:55:17 -04:00
Update fmt functions
This commit is contained in:
parent
740f5ef96f
commit
994d4374b9
@ -13,9 +13,9 @@ action:
|
||||
aliases: [/functions/errorf]
|
||||
---
|
||||
|
||||
The documentation for [Go's fmt package] describes the structure and content of the format string.
|
||||
{{% include "functions/fmt/_common/fmt-layout.md" %}}
|
||||
|
||||
Like the [`printf`] function, the `errorf` function evaluates the format string. It then prints the result to the ERROR log and fails the build. Hugo prints each unique message once to avoid flooding the log with duplicate errors.
|
||||
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 }}
|
||||
@ -24,5 +24,3 @@ Like the [`printf`] function, the `errorf` function evaluates the format string
|
||||
Use the [`erroridf`] function to allow optional suppression of specific errors.
|
||||
|
||||
[`erroridf`]: /functions/fmt/erroridf
|
||||
[`printf`]: /functions/fmt/printf
|
||||
[Go's fmt package]: https://pkg.go.dev/fmt
|
||||
|
@ -13,16 +13,14 @@ action:
|
||||
aliases: [/functions/erroridf]
|
||||
---
|
||||
|
||||
The documentation for [Go's fmt package] describes the structure and content of the format string.
|
||||
{{% include "functions/fmt/_common/fmt-layout.md" %}}
|
||||
|
||||
Like the [`errorf`] function, the `erroridf` function evaluates the format string, prints the result to the ERROR log, then fails the build. Hugo prints each unique message once to avoid flooding the log with duplicate errors.
|
||||
|
||||
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 `ignoreErrors` array in your site configuration.
|
||||
|
||||
This template code:
|
||||
|
||||
```go-html-template
|
||||
{{ erroridf "error-42" "You should consider fixing this." }}
|
||||
{{ erroridf "The %q shortcode was unable to find %s. See %s" .Name $file .Position }}
|
||||
```
|
||||
|
||||
Produces this console log:
|
||||
@ -40,4 +38,3 @@ ignoreErrors = ["error-42"]
|
||||
{{< /code-toggle >}}
|
||||
|
||||
[`errorf`]: /functions/fmt/errorf
|
||||
[Go's fmt package]: https://pkg.go.dev/fmt
|
||||
|
@ -13,9 +13,7 @@ action:
|
||||
aliases: [/functions/printf]
|
||||
---
|
||||
|
||||
The documentation for [Go's fmt package] describes the structure and content of the format string.
|
||||
|
||||
[Go's fmt package]: https://pkg.go.dev/fmt
|
||||
{{% include "functions/fmt/_common/fmt-layout.md" %}}
|
||||
|
||||
```go-html-template
|
||||
{{ $var := "world" }}
|
||||
|
@ -13,13 +13,10 @@ action:
|
||||
aliases: [/functions/warnf]
|
||||
---
|
||||
|
||||
The documentation for [Go's fmt package] describes the structure and content of the format string.
|
||||
{{% include "functions/fmt/_common/fmt-layout.md" %}}
|
||||
|
||||
Like the [`printf`] function, the `warnf` function evaluates the format string. It then prints the result to the WARNING log. Hugo prints each unique message once to avoid flooding the log with duplicate warnings.
|
||||
The `warnf` function evaluates the format string, then prints the result to the WARNING log. Hugo prints each unique message once to avoid flooding the log with duplicate warnings.
|
||||
|
||||
```go-html-template
|
||||
{{ warnf "Copyright notice missing from site configuration" }}
|
||||
{{ warnf "The %q shortcode was unable to find %s. See %s" .Name $file .Position }}
|
||||
```
|
||||
|
||||
[`printf`]: /functions/fmt/printf
|
||||
[Go's fmt package]: https://pkg.go.dev/fmt
|
||||
|
13
content/en/functions/fmt/_common/_index.md
Normal file
13
content/en/functions/fmt/_common/_index.md
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
cascade:
|
||||
_build:
|
||||
list: never
|
||||
publishResources: false
|
||||
render: never
|
||||
---
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
7
content/en/functions/fmt/_common/fmt-layout.md
Normal file
7
content/en/functions/fmt/_common/fmt-layout.md
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
# Do not remove front matter.
|
||||
---
|
||||
|
||||
The documentation for Go's [fmt] package describes the structure and content of the format string.
|
||||
|
||||
[fmt]: https://pkg.go.dev/fmt
|
Loading…
x
Reference in New Issue
Block a user