// return that error, more specific
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() {
func TestShortcodeNoInner(t *testing.T) {
t.Parallel()
- b := newTestSitesBuilder(t)
-
- b.WithContent("mypage.md", `---
+ files := `
+-- hugo.toml --
+baseURL = "https://example.org"
+disableKinds = ["term", "taxonomy", "home", "section"]
+-- content/mypage.md --
+---
title: "No Inner!"
---
+
{{< noinner >}}{{< /noinner >}}
+-- layouts/shortcodes/noinner.html --
+No inner here.
+-- layouts/_default/single.html --
+Content: {{ .Content }}|
-`).WithTemplatesAdded(
- "layouts/shortcodes/noinner.html", `No inner here.`)
+`
+
+ b, err := TestE(t, files)
+
+ 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`))
+ }
- err := b.BuildE(BuildCfg{})
- 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()
+
+ b, err = TestE(t, strings.Replace(files, `{{< noinner >}}{{< /noinner >}}`, `{{< noinner />}}`, 1))
+
+ assert()
}
func TestShortcodeStableOutputFormatTemplates(t *testing.T) {