Merge commit '8b9803425e63e1b1801f8d5d676e96368d706722'

This commit is contained in:
Bjørn Erik Pedersen
2024-06-21 09:41:24 +02:00
475 changed files with 7408 additions and 4720 deletions

View File

@@ -11,10 +11,10 @@ menu:
weight: 40
---
Use the [`jsonify`] function to inspect a data structure:
Use the [`debug.Dump`] function to inspect a data structure:
```go-html-template
<pre>{{ jsonify (dict "indent" " ") .Params }}</pre>
<pre>{{ debug.Dump .Params }}</pre>
```
```text
@@ -32,33 +32,6 @@ Use the [`jsonify`] function to inspect a data structure:
}
```
{{% note %}}
Hugo will throw an error if you attempt to use the construct above to display context that includes a page collection. For example, in a home page template, this will fail:
`{{ jsonify (dict "indent" " ") . }}`
{{% /note %}}
Use the [`debug.Dump`] function to inspect data types:
```go-html-template
<pre>{{ debug.Dump .Params }}</pre>
```
```text
maps.Params{
"date": time.Time{},
"draft": false,
"iscjklanguage": false,
"lastmod": time.Time{},
"publishdate": time.Time{},
"tags": []string{
"foo",
"bar",
},
"title": "My first post",
}
```
Use the [`printf`] function (render) or [`warnf`] function (log to console) to inspect simple data structures. The layout string below displays both value and data type.
```go-html-template
@@ -66,7 +39,6 @@ Use the [`printf`] function (render) or [`warnf`] function (log to console) to i
{{ printf "%[1]v (%[1]T)" $value }} → 42 (int)
```
[`jsonify`]: /functions/encoding/jsonify
[`debug.Dump`]: /functions/debug/dump
[`printf`]: /functions/fmt/printf
[`warnf`]: /functions/fmt/warnf
[`debug.Dump`]: /functions/debug/dump/
[`printf`]: /functions/fmt/printf/
[`warnf`]: /functions/fmt/warnf/