mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
tpl: Narrow down the usage of plain text shortcodes when rendering HTML
After this commit, if you want to resolve `layouts/_shortcodes/myshortcode.txt` when rendering HTML content, you need to use the `{{%` shortcode delimiter: ``` {{% myshortcode %}} ``` This should be what people would do anyway, but we have also as part of this improved the error message to inform about what needs to be done. Note that this is not relevant for partials. Fixes #13698
This commit is contained in:
@@ -920,6 +920,26 @@ func TestPartialHTML(t *testing.T) {
|
||||
b.AssertFileContent("public/index.html", "<link rel=\"stylesheet\" href=\"/css/style.css\">")
|
||||
}
|
||||
|
||||
func TestPartialPlainTextInHTML(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
-- layouts/all.html --
|
||||
<html>
|
||||
<head>
|
||||
{{ partial "mypartial.txt" . }}
|
||||
</head>
|
||||
</html>
|
||||
-- layouts/partials/mypartial.txt --
|
||||
My <div>partial</div>.
|
||||
`
|
||||
|
||||
b := hugolib.Test(t, files)
|
||||
|
||||
b.AssertFileContent("public/index.html", "My <div>partial</div>.")
|
||||
}
|
||||
|
||||
// Issue #13593.
|
||||
func TestGoatAndNoGoat(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -1103,6 +1123,18 @@ All.
|
||||
b.AssertLogContains("unrecognized render hook")
|
||||
}
|
||||
|
||||
func TestLayoutNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
-- layouts/single.html --
|
||||
Single.
|
||||
`
|
||||
b := hugolib.Test(t, files, hugolib.TestOptWarn())
|
||||
b.AssertLogContains("WARN found no layout file for \"html\" for kind \"home\"")
|
||||
}
|
||||
|
||||
func TestLayoutOverrideThemeWhenThemeOnOldFormatIssue13715(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -1214,8 +1246,8 @@ s2.
|
||||
Category: tplimpl.CategoryShortcode,
|
||||
Desc: desc,
|
||||
}
|
||||
v := store.LookupShortcode(q)
|
||||
if v == nil {
|
||||
v, err := store.LookupShortcode(q)
|
||||
if v == nil || err != nil {
|
||||
b.Fatal("not found")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user