mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-27 14:10:31 +03:00
Catch incomplete shortcode error
Currently, no name shortcodes (`{{< >}}`) enter unexpected branch and throw `BUG: template info not set`. This patch checks if shortcode has name or not earlier and throws specific error. Closes #6866
This commit is contained in:
parent
10f60de89a
commit
845a7ba4fc
2 changed files with 18 additions and 9 deletions
|
@ -65,8 +65,9 @@ title: "Title"
|
|||
t.Fatalf("Shortcode rendered error %s.", err)
|
||||
}
|
||||
|
||||
if err == nil && expectError {
|
||||
t.Fatalf("No error from shortcode")
|
||||
if expectError {
|
||||
c.Assert(err, qt.ErrorMatches, expected)
|
||||
return
|
||||
}
|
||||
|
||||
h := b.H
|
||||
|
@ -341,6 +342,12 @@ func TestShortcodeWrappedInPIssue(t *testing.T) {
|
|||
`, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", wt)
|
||||
}
|
||||
|
||||
// #6866
|
||||
func TestShortcodeIncomplete(t *testing.T) {
|
||||
t.Parallel()
|
||||
CheckShortCodeMatchAndError(t, `{{< >}}`, ".*shortcode has no name.*", nil, true)
|
||||
}
|
||||
|
||||
func TestExtractShortcodes(t *testing.T) {
|
||||
b := newTestSitesBuilder(t).WithSimpleConfigFile()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue