mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-19 21:21:39 +02:00
parser/pageparser: Fix handling of commented out front matter
When the page parser was rewritten in 0.51, this was interpreted literally, but commented out front matter is used in the wild to "hide it from GitHub", e.g: ``` <!-- +++ title = "hello" +++ --> ``` Fixes #5478
This commit is contained in:
@@ -1586,6 +1586,33 @@ CONTENT:{{ .Content }}
|
||||
)
|
||||
}
|
||||
|
||||
// https://github.com/gohugoio/hugo/issues/5478
|
||||
func TestPageWithCommentedOutFrontMatter(t *testing.T) {
|
||||
b := newTestSitesBuilder(t)
|
||||
b.WithSimpleConfigFile()
|
||||
|
||||
b.WithContent("page.md", `<!--
|
||||
+++
|
||||
title = "hello"
|
||||
+++
|
||||
-->
|
||||
This is the content.
|
||||
`)
|
||||
|
||||
b.WithTemplatesAdded("layouts/_default/single.html", `
|
||||
Title: {{ .Title }}
|
||||
Content:{{ .Content }}
|
||||
`)
|
||||
|
||||
b.CreateSites().Build(BuildCfg{})
|
||||
|
||||
b.AssertFileContent("public/page/index.html",
|
||||
"Title: hello",
|
||||
"Content:<p>This is the content.</p>",
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
// TODO(bep) this may be useful for other tests.
|
||||
func compareObjects(a interface{}, b interface{}) bool {
|
||||
aStr := strings.Split(fmt.Sprintf("%v", a), "")
|
||||
|
Reference in New Issue
Block a user