From 315d2f8c342c08c694080d08e055670051448b5e Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Thu, 7 Dec 2023 07:05:36 -0800 Subject: [PATCH] Add math.Counter example to warnf --- content/en/functions/fmt/Warnf.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/content/en/functions/fmt/Warnf.md b/content/en/functions/fmt/Warnf.md index b07cf3cc3..95edbc14e 100644 --- a/content/en/functions/fmt/Warnf.md +++ b/content/en/functions/fmt/Warnf.md @@ -20,3 +20,14 @@ The `warnf` function evaluates the format string, then prints the result to the ```go-html-template {{ warnf "The %q shortcode was unable to find %s. See %s" .Name $file .Position }} ``` + +To prevent supression of duplicate messages when using `warnf` for debugging, make each message unique with the [`math.Counter`] function. For example: + + +```go-html-template +{{ range site.RegularPages }} + {{ .Section | warnf "%#[2]v [%[1]d]" math.Counter }} +{{ end }} +``` + +[`math.Counter`]: /functions/math/counter