content adapter: Fix issue with content starting out with a shortcode

Fixes #12544
This commit is contained in:
Bjørn Erik Pedersen
2024-05-29 12:59:57 +02:00
parent 7f3061723e
commit 519f41dbd7
4 changed files with 43 additions and 10 deletions

View File

@@ -585,3 +585,28 @@ value: data1
b.AssertLogNotContains("WARN")
}
func TestPagesFromGoTmplShortcodeNoPreceddingCharacterIssue12544(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
-- content/_content.gotmpl --
{{ $content := dict "mediaType" "text/html" "value" "x{{< sc >}}" }}
{{ .AddPage (dict "content" $content "path" "a") }}
{{ $content := dict "mediaType" "text/html" "value" "{{< sc >}}" }}
{{ .AddPage (dict "content" $content "path" "b") }}
-- layouts/_default/single.html --
|{{ .Content }}|
-- layouts/shortcodes/sc.html --
foo
{{- /**/ -}}
`
b := hugolib.Test(t, files)
b.AssertFileContent("public/a/index.html", "|xfoo|")
b.AssertFileContent("public/b/index.html", "|foo|") // fails
}