tpl: Do not return any value in errorf
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 21 Dec 2019 09:26:14 +0000 (10:26 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 21 Dec 2019 09:26:14 +0000 (10:26 +0100)
Fixes #6653

docs/content/en/functions/errorf.md
tpl/fmt/fmt.go
tpl/fmt/init.go

index edc8e5755ac2d447ff333d1bc629f56552e69bd4..9cd7e69b62b3b7e5626f0acb91166590a0c24cc3 100644 (file)
@@ -14,14 +14,14 @@ workson: []
 hugoversion:
 relatedfuncs: [printf]
 deprecated: false
-aliases: []
+aliases: [/functions/errorf]
 ---
 
 `errorf` or `warnf` will evaluate a format string, then output the result to the ERROR or WARNING log (and only once per error message to avoid flooding the log).
 
 Any ERROR will also cause the build to fail (the `hugo` command will `exit -1`).
 
-Note that the WARNING will only be printed to the console.
+Both functions return an empty string, so the messages are only printed to the console.
 
 ```
 {{ errorf "Failed to handle page %q" .Path }}
index 7e0258650b0cc45a862dd2f0017ffd60ffe2f7a8..aa6b8c1a636092ad3eb9903bf31d006bd3ff18e9 100644 (file)
@@ -51,11 +51,11 @@ func (ns *Namespace) Println(a ...interface{}) string {
        return _fmt.Sprintln(a...)
 }
 
-// Errorf formats according to a format specifier and returns the string as a
-// value that satisfies error.
+// Errorf formats according to a format specifier and logs an ERROR.
+// It returns an empty string.
 func (ns *Namespace) Errorf(format string, a ...interface{}) string {
        ns.errorLogger.Printf(format, a...)
-       return _fmt.Sprintf(format, a...)
+       return ""
 }
 
 // Warnf formats according to a format specifier and logs a WARNING.
index 14568b45ab905e992d590c8c17d7b8ce522f2047..6a2c9a856ca397dedb1889b5accc5dd05c537005 100644 (file)
@@ -53,7 +53,7 @@ func init() {
                ns.AddMethodMapping(ctx.Errorf,
                        []string{"errorf"},
                        [][2]string{
-                               {`{{ errorf "%s." "failed" }}`, `failed.`},
+                               {`{{ errorf "%s." "failed" }}`, ``},
                        },
                )