How to inspect variables in the current scope in Hugo?

Viewed 272

I'm trying to see what variables are available under "the dot".

According to the docs, {{ printf "%#v" . }} is what I'm looking for.

But it only seems to print a bunch of memory adresses.

For instance, in a place where the dot contains .Params and a bunch of other variables, this is what {{ printf "%#v" . }} yields:

&hugolib.pageState{pageOutputs:[]*hugolib.pageOutput{(*hugolib.pageOutput)(0xc0008cad80),
(*hugolib.pageOutput)(0xc0008cafc0)},
pageOutput:(*hugolib.pageOutput)(0xc0008cad80),
pageCommon:(*hugolib.pageCommon)(0xc00052b400)}

I'm not sure what that is, but it doesn't mention what is available in the current context.

1 Answers

So I asked the same question in Hugo's discourse community and Bjørn Erik Pedersen (creator of Hugo) suggested the following:

 {{ debug.Dump . }}

and

 {{ . | jsonify (dict "indent" " ") }}

I've had more luck with the latter.

Related