Error on upgrade to v0.74.3 with replaceRE

I’ve just updated Hugo version from v0.70.0 to v.0.74.3, and I now get the following error message on build:

(replaceRE "[^a-zA-Z0-9]+" "-" (lower .Params.publisher)) .Params.publisher | _html_template_urlnormalizer | _html_template_attrescaper>: can't give argument to non-function replaceRE "[^a-zA-Z0-9]+" "-" (lower .Params.publisher)

This is the code it’s complaining about:

<img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="/img/books/{{(replaceRE "[^a-zA-Z0-9]+" "-" (lower .Params.publisher)) .Params.publisher}} alt="{{.Params.publisher}}" />

What does this mean?

This:

{{(replaceRE "[^a-zA-Z0-9]+" "-" (lower .Params.publisher)) .Params.publisher}}

is similar to:

{{ $a := "foo" }}
{{ $b := "bar" }}
{{ $a $b }}

which correctly throws this error:

can't give argument to non-function $a

This was not throwing an error in previous versions due to a bug in the Go templating package.

2 Likes

First time I miss a bug :wink:

Thanks as always for the detailed answer.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.