diff --git a/content/en/functions/debug/Dump.md b/content/en/functions/debug/Dump.md index ed549c081..67b264bed 100644 --- a/content/en/functions/debug/Dump.md +++ b/content/en/functions/debug/Dump.md @@ -11,33 +11,22 @@ action: --- ```go-html-template -{{ $data := dict }} -{{ $p := "data/books.json" }} -{{ with resources.Get $p }} - {{ $opts := dict "delimiter" "," }} - {{ $data = .Content | transform.Unmarshal $opts }} -{{ else }} - {{ errorf "Unable to get resource %q" $p }} -{{ end }} +
{{ debug.Dump site.Data.books }}
```
-```go-html-template
-{{ debug.Dump $data }}
-```
-
-```text
-[]interface {}{
- map[string]interface {}{
+```json
+[
+ {
"author": "Victor Hugo",
- "rating": 5.0,
- "title": "Les Misérables",
+ "rating": 4,
+ "title": "The Hunchback of Notre Dame"
},
- map[string]interface {}{
+ {
"author": "Victor Hugo",
- "rating": 4.0,
- "title": "The Hunchback of Notre Dame",
- },
-}
+ "rating": 5,
+ "title": "Les Misérables"
+ }
+]
```
{{% note %}}
diff --git a/content/en/functions/transform/Unmarshal.md b/content/en/functions/transform/Unmarshal.md
index 70a12097e..5786a1dcb 100644
--- a/content/en/functions/transform/Unmarshal.md
+++ b/content/en/functions/transform/Unmarshal.md
@@ -182,7 +182,7 @@ Get the remote data:
Inspect the data structure:
```go-html-template
-{{ jsonify (dict "indent" " ") $data }}
+{{ debug.Dump $data }}
```
List the book titles:
@@ -245,7 +245,7 @@ Let's add a `lang` attribute to the `title` nodes of our RSS feed, and a namespa
After retrieving the remote data, inspect the data structure:
```go-html-template
-{{ jsonify (dict "indent" " ") $data }}
+{{ debug.Dump $data }}
```
Each item node looks like this:
diff --git a/content/en/methods/page/Fragments.md b/content/en/methods/page/Fragments.md
index 11ab50fd8..7bcad1ef9 100644
--- a/content/en/methods/page/Fragments.md
+++ b/content/en/methods/page/Fragments.md
@@ -31,21 +31,21 @@ Headings
: (`map`) A nested map of all headings on the page. Each map contains the following keys: `ID`, `Level`, `Title` and `Headings`. To inspect the data structure:
```go-html-template
-{{ .Fragments.Headings | jsonify (dict "indent" " ") }}
+{{ debug.Dump .Fragments.Headings }}
```
HeadingsMap
: (`slice`) A slice of maps of all headings on the page, with first-level keys for each heading. Each map contains the following keys: `ID`, `Level`, `Title` and `Headings`. To inspect the data structure:
```go-html-template
-{{ .Fragments.HeadingsMap | jsonify (dict "indent" " ") }}
+{{ debug.Dump .Fragments.HeadingsMap }}
```
Identifiers
: (`slice`) A slice containing the `id` of each heading on the page. To inspect the data structure:
```go-html-template
-{{ .Fragments.Identifiers | jsonify (dict "indent" " ") }}
+{{ debug.Dump .Fragments.Identifiers }}
```
Identifiers.Contains ID
diff --git a/content/en/methods/site/Languages.md b/content/en/methods/site/Languages.md
index 26bdefc21..cfa1ade6b 100644
--- a/content/en/methods/site/Languages.md
+++ b/content/en/methods/site/Languages.md
@@ -12,10 +12,10 @@ action:
The `Languages` method on a `Site` object returns a collection of language objects for all sites, ordered by language weight. Each language object points to its language definition in the site configuration.
-To view the data structure:
+To inspect the data structure:
```go-html-template
-{{ jsonify (dict "indent" " ") .Site.Languages }}
+{{ debug.Dump .Site.Languages }}
```
With this site configuration:
diff --git a/content/en/methods/taxonomy/Alphabetical.md b/content/en/methods/taxonomy/Alphabetical.md
index 7845dbf3d..ea90cfdf9 100644
--- a/content/en/methods/taxonomy/Alphabetical.md
+++ b/content/en/methods/taxonomy/Alphabetical.md
@@ -34,7 +34,7 @@ To reverse the sort order:
To inspect the data structure:
```go-html-template
-{{ jsonify (dict "indent" " ") $taxonomyObject.Alphabetical }}
+{{ debug.Dump $taxonomyObject.Alphabetical }}
```
{{% include "methods/taxonomy/_common/ordered-taxonomy-element-methods.md" %}}
diff --git a/content/en/methods/taxonomy/ByCount.md b/content/en/methods/taxonomy/ByCount.md
index 40f58420a..68143ccff 100644
--- a/content/en/methods/taxonomy/ByCount.md
+++ b/content/en/methods/taxonomy/ByCount.md
@@ -34,7 +34,7 @@ To reverse the sort order:
To inspect the data structure:
```go-html-template
-{{ jsonify (dict "indent" " ") $taxonomyObject.ByCount }}
+{{ debug.Dump $taxonomyObject.ByCount }}
```
{{% include "methods/taxonomy/_common/ordered-taxonomy-element-methods.md" %}}
diff --git a/content/en/methods/taxonomy/Get.md b/content/en/methods/taxonomy/Get.md
index 07a20ca47..79d25b704 100644
--- a/content/en/methods/taxonomy/Get.md
+++ b/content/en/methods/taxonomy/Get.md
@@ -43,7 +43,7 @@ You could also use the [`index`] function, but the syntax is more verbose:
To inspect the data structure:
```go-html-template
-{{ jsonify (dict "indent" " ") $weightedPages }}
+{{ debug.Dump $weightedPages }}
```
## Example
diff --git a/content/en/methods/taxonomy/_common/get-a-taxonomy-object.md b/content/en/methods/taxonomy/_common/get-a-taxonomy-object.md
index abfe4fbec..6bf86cd85 100644
--- a/content/en/methods/taxonomy/_common/get-a-taxonomy-object.md
+++ b/content/en/methods/taxonomy/_common/get-a-taxonomy-object.md
@@ -41,7 +41,7 @@ To capture the "genres" taxonomy object when rendering its page with a taxonomy
To inspect the data structure:
```go-html-template
-{{ jsonify (dict "indent" " ") $taxonomyObject }}
+{{ debug.Dump $taxonomyObject }}
```
Although the [`Alphabetical`] and [`ByCount`] methods provide a better data structure for ranging through the taxonomy, you can render the weighted pages by term directly from the `Taxonomy` object:
diff --git a/content/en/troubleshooting/inspection.md b/content/en/troubleshooting/inspection.md
index 1820644fa..e9fc8ed0f 100644
--- a/content/en/troubleshooting/inspection.md
+++ b/content/en/troubleshooting/inspection.md
@@ -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
-{{ jsonify (dict "indent" " ") .Params }}
+{{ debug.Dump .Params }}
```
```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
-{{ debug.Dump .Params }}
-```
-
-```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/