mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-28 14:40:43 +03:00
Fix shortcode name in error message on self-closing shortcodes with no .Inner
Fixes #13344
This commit is contained in:
parent
377287a614
commit
e865d59844
2 changed files with 28 additions and 8 deletions
|
@ -650,7 +650,11 @@ Loop:
|
||||||
// return that error, more specific
|
// return that error, more specific
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("%s: shortcode %q does not evaluate .Inner or .InnerDeindent, yet a closing tag was provided", errorPrefix, next.ValStr(source))
|
name := sc.name
|
||||||
|
if name == "" {
|
||||||
|
name = next.ValStr(source)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("%s: shortcode %q does not evaluate .Inner or .InnerDeindent, yet a closing tag was provided", errorPrefix, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if next.IsRightShortcodeDelim() {
|
if next.IsRightShortcodeDelim() {
|
||||||
|
|
|
@ -831,19 +831,35 @@ title: "Hugo Rocks!"
|
||||||
func TestShortcodeNoInner(t *testing.T) {
|
func TestShortcodeNoInner(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
b := newTestSitesBuilder(t)
|
files := `
|
||||||
|
-- hugo.toml --
|
||||||
b.WithContent("mypage.md", `---
|
baseURL = "https://example.org"
|
||||||
|
disableKinds = ["term", "taxonomy", "home", "section"]
|
||||||
|
-- content/mypage.md --
|
||||||
|
---
|
||||||
title: "No Inner!"
|
title: "No Inner!"
|
||||||
---
|
---
|
||||||
|
|
||||||
{{< noinner >}}{{< /noinner >}}
|
{{< noinner >}}{{< /noinner >}}
|
||||||
|
|
||||||
|
-- layouts/shortcodes/noinner.html --
|
||||||
|
No inner here.
|
||||||
|
-- layouts/_default/single.html --
|
||||||
|
Content: {{ .Content }}|
|
||||||
|
|
||||||
`).WithTemplatesAdded(
|
`
|
||||||
"layouts/shortcodes/noinner.html", `No inner here.`)
|
|
||||||
|
|
||||||
err := b.BuildE(BuildCfg{})
|
b, err := TestE(t, files)
|
||||||
b.Assert(err.Error(), qt.Contains, filepath.FromSlash(`"content/mypage.md:4:16": failed to extract shortcode: shortcode "noinner" does not evaluate .Inner or .InnerDeindent, yet a closing tag was provided`))
|
|
||||||
|
assert := func() {
|
||||||
|
b.Assert(err.Error(), qt.Contains, filepath.FromSlash(`failed to extract shortcode: shortcode "noinner" does not evaluate .Inner or .InnerDeindent, yet a closing tag was provided`))
|
||||||
|
}
|
||||||
|
|
||||||
|
assert()
|
||||||
|
|
||||||
|
b, err = TestE(t, strings.Replace(files, `{{< noinner >}}{{< /noinner >}}`, `{{< noinner />}}`, 1))
|
||||||
|
|
||||||
|
assert()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestShortcodeStableOutputFormatTemplates(t *testing.T) {
|
func TestShortcodeStableOutputFormatTemplates(t *testing.T) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue