-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"is not a method but has arguments" error message is confusing #10862
Comments
Works,
Error, passing
Error:
|
Thanks, but I still don't understand the message. What sort of Foo.Bar is not a method but has arguments? |
The error comes from here: https://github.com/golang/go/blob/master/src/text/template/exec.go#L669 I agree that it would be useful to have the receiver type (a map of some sort) in the error message, but I'm afraid you need to convince the Go people to get that fix. |
To summarize, the issue is that the template context is a map without a matching key? Do I have that right? So any time a map doesn't have a key, text/template produces a "[key] is not a method but has arguments" error? |
This is also an issue that arose for us with the latest Hugo release (0.111.3 works, 0.112.1 doesn't). I'm not sure the context above is applicable to our case. I have:
The error is:
But, it looks like we always provide an argument to |
I haven't looked closely, but I suspect you have become a victim of my "API spring cleaning" project. A lot of work was put into getting some control over "what is the public API" of Hugo. I don't remember why that particular method was removed, but I don't see why you cannot just do:
which is a construct that works for all maps. |
Thanks! That should be easy to fix then. Since the removed "method" names are known, perhaps it would be useful to add error messages to catch common mistakes like this. |
`.Params.Get $key` has been deprecated; use `index .Params $key` instead. See gohugoio/hugo#10862 (comment)
`.Params.Get $key` has been deprecated; use `index .Params $key` instead. See gohugoio/hugo#10862 (comment)
Just got back into Hugo as I have new things to add to my website - but I'm running into this error, followed the suggestions above but to no avail. I last built my site using v0.109:
I have just upgraded to the latest version available on chocolatey:
My original code: {{- $fnStart := int (.Page.Params.Get "fnStart") -}} I've got a multi-page site that's essentially a book, and the footnote starting numbers are defined by a page parameter (in lieu of a some smarter solution, for now). This code produces I have tried:
Apologies I'm a little out of my depth on this syntax and would appreciate any help I can get! |
@SudoCerb Change this:
to either of these:
Although the |
I'm closing this, as this i'nt likely to be reverted. |
Any hope to update the cryptic error message? This is under the assumption that "Get" can easily be detected, but perhaps not. |
Thanks very much! This solved that issue! |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
With this template:
and this config.yaml:
I got this error:
I have no idea what this error message means.
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
Yes
The text was updated successfully, but these errors were encountered: