diff options
Diffstat (limited to 'docs/content/en/functions/fmt')
-rw-r--r-- | docs/content/en/functions/fmt/Errorf.md | 21 | ||||
-rw-r--r-- | docs/content/en/functions/fmt/Erroridf.md | 28 | ||||
-rw-r--r-- | docs/content/en/functions/fmt/Print.md | 19 | ||||
-rw-r--r-- | docs/content/en/functions/fmt/Printf.md | 19 | ||||
-rw-r--r-- | docs/content/en/functions/fmt/Println.md | 19 | ||||
-rw-r--r-- | docs/content/en/functions/fmt/Warnf.md | 24 | ||||
-rw-r--r-- | docs/content/en/functions/fmt/_common/_index.md | 13 | ||||
-rw-r--r-- | docs/content/en/functions/fmt/_common/fmt-layout.md | 7 | ||||
-rw-r--r-- | docs/content/en/functions/fmt/_index.md | 12 |
9 files changed, 77 insertions, 85 deletions
diff --git a/docs/content/en/functions/fmt/Errorf.md b/docs/content/en/functions/fmt/Errorf.md index da9845073..bbdd62c53 100644 --- a/docs/content/en/functions/fmt/Errorf.md +++ b/docs/content/en/functions/fmt/Errorf.md @@ -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 diff --git a/docs/content/en/functions/fmt/Erroridf.md b/docs/content/en/functions/fmt/Erroridf.md index 986810436..9884f4935 100644 --- a/docs/content/en/functions/fmt/Erroridf.md +++ b/docs/content/en/functions/fmt/Erroridf.md @@ -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 diff --git a/docs/content/en/functions/fmt/Print.md b/docs/content/en/functions/fmt/Print.md index f9ff885f8..6f3128e5f 100644 --- a/docs/content/en/functions/fmt/Print.md +++ b/docs/content/en/functions/fmt/Print.md @@ -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] ``` diff --git a/docs/content/en/functions/fmt/Printf.md b/docs/content/en/functions/fmt/Printf.md index 06b7222e9..5d0127460 100644 --- a/docs/content/en/functions/fmt/Printf.md +++ b/docs/content/en/functions/fmt/Printf.md @@ -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" }} diff --git a/docs/content/en/functions/fmt/Println.md b/docs/content/en/functions/fmt/Println.md index 358b5f8ac..a4db56ffb 100644 --- a/docs/content/en/functions/fmt/Println.md +++ b/docs/content/en/functions/fmt/Println.md @@ -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 ``` diff --git a/docs/content/en/functions/fmt/Warnf.md b/docs/content/en/functions/fmt/Warnf.md index be579a216..b07cf3cc3 100644 --- a/docs/content/en/functions/fmt/Warnf.md +++ b/docs/content/en/functions/fmt/Warnf.md @@ -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 diff --git a/docs/content/en/functions/fmt/_common/_index.md b/docs/content/en/functions/fmt/_common/_index.md new file mode 100644 index 000000000..47d5812fb --- /dev/null +++ b/docs/content/en/functions/fmt/_common/_index.md @@ -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. +--> diff --git a/docs/content/en/functions/fmt/_common/fmt-layout.md b/docs/content/en/functions/fmt/_common/fmt-layout.md new file mode 100644 index 000000000..ff69ce5e4 --- /dev/null +++ b/docs/content/en/functions/fmt/_common/fmt-layout.md @@ -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 diff --git a/docs/content/en/functions/fmt/_index.md b/docs/content/en/functions/fmt/_index.md new file mode 100644 index 000000000..51ef847ca --- /dev/null +++ b/docs/content/en/functions/fmt/_index.md @@ -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. |