mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-22 21:42:50 +02:00
Fix panic with debug.Dump with Page when running the server
This replaces the current implementation with `json.MarshalIndent` which doesn't produce the same output, but at least it doesn't crash. There's a bug in the upstream `litter` library. This can probably be fixed, but that needs to wait. I have tested `go-spew` which does not crash, but it is very data racy in this context. FIxes #12309
This commit is contained in:
@@ -43,3 +43,33 @@ disableKinds = ["taxonomy", "term"]
|
||||
|
||||
b.AssertLogContains("timer: name foo count 5 duration")
|
||||
}
|
||||
|
||||
func TestDebugDumpPage(t *testing.T) {
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
baseURL = "https://example.org/"
|
||||
disableLiveReload = true
|
||||
[taxonomies]
|
||||
tag = "tags"
|
||||
-- content/_index.md --
|
||||
---
|
||||
title: "The Index"
|
||||
date: 2012-03-15
|
||||
---
|
||||
-- content/p1.md --
|
||||
---
|
||||
title: "The First"
|
||||
tags: ["a", "b"]
|
||||
---
|
||||
-- layouts/_default/list.html --
|
||||
Dump: {{ debug.Dump . | safeHTML }}
|
||||
Dump Site: {{ debug.Dump site }}
|
||||
Dum site.Taxonomies: {{ debug.Dump site.Taxonomies | safeHTML }}
|
||||
-- layouts/_default/single.html --
|
||||
Dump: {{ debug.Dump . | safeHTML }}
|
||||
|
||||
|
||||
`
|
||||
b := hugolib.TestRunning(t, files)
|
||||
b.AssertFileContent("public/index.html", "Dump: {\n \"Date\": \"2012-03-15T00:00:00Z\"")
|
||||
}
|
||||
|
Reference in New Issue
Block a user