mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-19 21:21:39 +02:00
Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'
This commit is contained in:
@@ -1,26 +1,21 @@
|
||||
---
|
||||
title: fmt.Errorf
|
||||
linkTitle: errorf
|
||||
description: Log an ERROR from a template.
|
||||
categories: [functions]
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: functions
|
||||
function:
|
||||
action:
|
||||
aliases: [errorf]
|
||||
related:
|
||||
- functions/fmt/Erroridf
|
||||
- functions/fmt/Warnf
|
||||
returnType: string
|
||||
signatures: ['fmt.Errorf FORMAT [INPUT]']
|
||||
relatedFunctions:
|
||||
- fmt.Errorf
|
||||
- fmt.Erroridf
|
||||
- fmt.Warnf
|
||||
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 }}
|
||||
@@ -29,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
|
||||
|
@@ -1,28 +1,21 @@
|
||||
---
|
||||
title: fmt.Erroridf
|
||||
linkTitle: erroridf
|
||||
description: Log a suppressable ERROR from a template.
|
||||
categories: [functions]
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: functions
|
||||
function:
|
||||
action:
|
||||
aliases: [erroridf]
|
||||
related:
|
||||
- functions/fmt/Errorf
|
||||
- functions/fmt/Warnf
|
||||
returnType: string
|
||||
signatures: ['fmt.Erroridf ID FORMAT [INPUT]']
|
||||
relatedFunctions:
|
||||
- fmt.Errorf
|
||||
- fmt.Erroridf
|
||||
- fmt.Warnf
|
||||
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:
|
||||
|
||||
@@ -34,15 +27,14 @@ Produces this console log:
|
||||
|
||||
```text
|
||||
ERROR You should consider fixing this.
|
||||
If you feel that this should not be logged as an ERROR, you can ignore it by adding this to your site config:
|
||||
ignoreErrors = ["error-42"]
|
||||
You can suppress this error by adding the following to your site configuration:
|
||||
ignoreErrors = ['error-42']
|
||||
```
|
||||
|
||||
To suppress this message:
|
||||
|
||||
{{< code-toggle file=hugo copy=false >}}
|
||||
{{< code-toggle file=hugo >}}
|
||||
ignoreErrors = ["error-42"]
|
||||
{{< /code-toggle >}}
|
||||
|
||||
[`errorf`]: /functions/fmt/errorf
|
||||
[Go's fmt package]: https://pkg.go.dev/fmt
|
||||
|
@@ -1,25 +1,20 @@
|
||||
---
|
||||
title: fmt.Print
|
||||
linkTitle: print
|
||||
description: Prints the default representation of the given arguments using the standard `fmt.Print` function.
|
||||
categories: [functions]
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: functions
|
||||
function:
|
||||
action:
|
||||
aliases: [print]
|
||||
related:
|
||||
- functions/fmt/Printf
|
||||
- functions/fmt/Println
|
||||
returnType: string
|
||||
signatures: [fmt.Print INPUT]
|
||||
relatedFunctions:
|
||||
- fmt.Print
|
||||
- fmt.Printf
|
||||
- fmt.Println
|
||||
aliases: [/functions/print]
|
||||
---
|
||||
|
||||
```go-html-template
|
||||
{{ print "foo" }} → "foo"
|
||||
{{ print "foo" "bar" }} → "foobar"
|
||||
{{ print "foo" }} → foo
|
||||
{{ print "foo" "bar" }} → foobar
|
||||
{{ print (slice 1 2 3) }} → [1 2 3]
|
||||
```
|
||||
|
@@ -1,26 +1,19 @@
|
||||
---
|
||||
title: fmt.Printf
|
||||
linkTitle: printf
|
||||
description: Formats a string using the standard `fmt.Sprintf` function.
|
||||
categories: [functions]
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: functions
|
||||
function:
|
||||
action:
|
||||
aliases: [printf]
|
||||
related:
|
||||
- functions/fmt/Print
|
||||
- functions/fmt/Println
|
||||
returnType: string
|
||||
signatures: ['fmt.Printf FORMAT [INPUT]']
|
||||
relatedFunctions:
|
||||
- fmt.Print
|
||||
- fmt.Printf
|
||||
- fmt.Println
|
||||
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" }}
|
||||
|
@@ -1,23 +1,18 @@
|
||||
---
|
||||
title: fmt.Println
|
||||
linkTitle: println
|
||||
description: Prints the default representation of the given argument using the standard `fmt.Print` function and enforces a linebreak.
|
||||
categories: [functions]
|
||||
description: Prints the default representation of the given argument using the standard `fmt.Print` function and enforces a line break.
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: functions
|
||||
function:
|
||||
action:
|
||||
aliases: [println]
|
||||
related:
|
||||
- functions/fmt/Print
|
||||
- functions/fmt/Printf
|
||||
returnType: string
|
||||
signatures: [fmt.Println INPUT]
|
||||
relatedFunctions:
|
||||
- fmt.Print
|
||||
- fmt.Printf
|
||||
- fmt.Println
|
||||
aliases: [/functions/println]
|
||||
---
|
||||
|
||||
```go-html-template
|
||||
{{ println "foo" }} → "foo\n"
|
||||
{{ println "foo" }} → foo\n
|
||||
```
|
||||
|
@@ -1,30 +1,22 @@
|
||||
---
|
||||
title: fmt.Warnf
|
||||
linkTitle: warnf
|
||||
description: Log a WARNING from a template.
|
||||
categories: [functions]
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: functions
|
||||
function:
|
||||
action:
|
||||
aliases: [warnf]
|
||||
related:
|
||||
- functions/fmt/Errorf
|
||||
- functions/fmt/Erroridf
|
||||
returnType: string
|
||||
signatures: ['fmt.Warnf FORMAT [INPUT]']
|
||||
relatedFunctions:
|
||||
- fmt.Errorf
|
||||
- fmt.Erroridf
|
||||
- fmt.Warnf
|
||||
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
docs/content/en/functions/fmt/_common/_index.md
Normal file
13
docs/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
docs/content/en/functions/fmt/_common/fmt-layout.md
Normal file
7
docs/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
|
12
docs/content/en/functions/fmt/_index.md
Normal file
12
docs/content/en/functions/fmt/_index.md
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: Fmt functions
|
||||
linkTitle: fmt
|
||||
description: Template functions to print strings within a template or to print messages to the terminal
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: functions
|
||||
---
|
||||
|
||||
Use these functions to print strings within a template or to print messages to the terminal.
|
Reference in New Issue
Block a user