Reimplement and simplify Hugo's template system

See #13541 for details.

Fixes #13545
Fixes #13515
Closes #7964
Closes #13365
Closes #12988
Closes #4891
This commit is contained in:
Bjørn Erik Pedersen
2025-04-06 19:55:35 +02:00
parent 812ea0b325
commit 83cfdd78ca
138 changed files with 5342 additions and 4396 deletions

View File

@@ -242,8 +242,13 @@ Data en
}
func TestBundleMultipleContentPageWithSamePath(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
printPathWarnings = true
-- layouts/all.html --
All.
-- content/bundle/index.md --
---
title: "Bundle md"
@@ -273,14 +278,18 @@ Bundle: {{ $bundle.Title }}|{{ $bundle.Params.foo }}|{{ $bundle.File.Filename }}
P1: {{ $p1.Title }}|{{ $p1.Params.foo }}|{{ $p1.File.Filename }}|
`
b := Test(t, files)
for range 3 {
b := Test(t, files, TestOptWarn())
// There's multiple content files sharing the same logical path and language.
// This is a little arbitrary, but we have to pick one and prefer the Markdown version.
b.AssertFileContent("public/index.html",
filepath.FromSlash("Bundle: Bundle md|md|/content/bundle/index.md|"),
filepath.FromSlash("P1: P1 md|md|/content/p1.md|"),
)
b.AssertLogContains("WARN Duplicate content path: \"/p1\"")
// There's multiple content files sharing the same logical path and language.
// This is a little arbitrary, but we have to pick one and prefer the Markdown version.
b.AssertFileContent("public/index.html",
filepath.FromSlash("Bundle: Bundle md|md|/content/bundle/index.md|"),
filepath.FromSlash("P1: P1 md|md|/content/p1.md|"),
)
}
}
// Issue #11944