mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-26 21:51:02 +03:00
tpl: Fix it so we always prefer internal codeblock rendering over render-codeblock-foo.html and similar
Fixes #13651
This commit is contained in:
parent
5c491409d3
commit
408791d657
2 changed files with 33 additions and 9 deletions
|
@ -130,17 +130,12 @@ func (this TemplateDescriptor) doCompare(category Category, isEmbedded bool, def
|
||||||
|
|
||||||
// One example of variant1 and 2 is for render codeblocks:
|
// One example of variant1 and 2 is for render codeblocks:
|
||||||
// variant1=codeblock, variant2=go (language).
|
// variant1=codeblock, variant2=go (language).
|
||||||
if other.Variant1 != "" && other.Variant1 != this.Variant1 {
|
if other.Variant1 != "" {
|
||||||
return w
|
if other.Variant1 != this.Variant1 {
|
||||||
}
|
|
||||||
|
|
||||||
if isEmbedded {
|
|
||||||
if other.Variant2 != "" && other.Variant2 != this.Variant2 {
|
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// If both are set and different, no match.
|
if other.Variant2 != "" && other.Variant2 != this.Variant2 {
|
||||||
if other.Variant2 != "" && this.Variant2 != "" && other.Variant2 != this.Variant2 {
|
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1038,6 +1038,35 @@ _markup/render-codeblock-goat.html
|
||||||
b.AssertFileContent("public/index.html", "_markup/render-codeblock.html_markup/render-codeblock-goat.html")
|
b.AssertFileContent("public/index.html", "_markup/render-codeblock.html_markup/render-codeblock-goat.html")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLookupCodeblockIssue13651(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
files := `
|
||||||
|
-- hugo.toml --
|
||||||
|
-- layouts/all.html --
|
||||||
|
{{ .Content }}|
|
||||||
|
-- layouts/_markup/render-codeblock-foo.html --
|
||||||
|
render-codeblock-foo.html
|
||||||
|
-- content/_index.md --
|
||||||
|
---
|
||||||
|
---
|
||||||
|
|
||||||
|
§§§
|
||||||
|
printf "Hello, world!"
|
||||||
|
§§§
|
||||||
|
|
||||||
|
§§§ foo
|
||||||
|
printf "Hello, world again!"
|
||||||
|
§§§
|
||||||
|
`
|
||||||
|
|
||||||
|
b := hugolib.Test(t, files)
|
||||||
|
|
||||||
|
content := b.FileContent("public/index.html")
|
||||||
|
fooCount := strings.Count(content, "render-codeblock-foo.html")
|
||||||
|
b.Assert(fooCount, qt.Equals, 1)
|
||||||
|
}
|
||||||
|
|
||||||
// Issue #13515
|
// Issue #13515
|
||||||
func TestPrintPathWarningOnDotRemoval(t *testing.T) {
|
func TestPrintPathWarningOnDotRemoval(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue