gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
74.82k stars 7.46k forks source link

Regression on listing context variables for template debug - method from documentation no longer works #11460

Open Japanuspus opened 1 year ago

Japanuspus commented 1 year ago

The documentation on "template debugging" describes a simple way to render all Site context variables via

{{ printf "%#v" $.Site }}

As of v0.118.2, using this approach gives the output:

&page.siteWrapper{s:(*hugolib.Site)(0x140009c22c0)}

instead of the expected listing of $.Site-properties.

The regression appears to caused by introducing an indirection via the siteWrapper-object (introduced in 241b21b0fd34d91fccb2ce69874110dceae6f926).

What version of Hugo are you using (hugo version)?

hugo v0.118.2-da7983ac4b94d97d776d7c2405040de97e95c03d+extended darwin/arm64 BuildDate=2023-08-31T11:23:51Z VendorInfo=brew

Does this issue reproduce with the latest release?

Yes

Japanuspus commented 1 year ago

I have previously contributed fixes to Hugo, but I am no golang expert and do not know enough about reflection/introspection in golang to offer any help on this.

As a casual Hugo user, the listing of properties has been a great help in learning how to use the template system. If the previous functionality cannot easily be reestablished, it would be of great value if someone knowledgeable about golang could update the linked documentation to show how to inspect the wrapped objects.

tmuras commented 10 months ago

Still broken in hugo v0.120.1-16fb2cae88eb6add7d12e9fbfcf01d8670e60a35 . The output of {{ printf "%#v" $.Site }} is: &page.siteWrapper{s:(*hugolib.Site)(0xc00071d8c0)}

jmooring commented 10 months ago

Still broken in hugo v0.120.1

Right. That's why the issue is still open.