Skip to content

Commit

Permalink
Add some shortcode testcases
Browse files Browse the repository at this point in the history
Closes #10671
  • Loading branch information
bep committed Feb 23, 2023
1 parent b99d073 commit 0dbeac8
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions hugolib/shortcode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1198,3 +1198,46 @@ C'est un test
b.AssertFileContent("public/fr/p2/index.html", `plus-dinformations`)

}

// Issue 10671.
func TestShortcodeInnerShouldBeEmptyWhenNotClosed(t *testing.T) {
t.Parallel()

files := `
-- config.toml --
disableKinds = ["home", "taxonomy", "term"]
-- content/p1.md --
---
title: "p1"
---
{{< sc "self-closing" />}}
Text.
{{< sc "closing-no-newline" >}}{{< /sc >}}
-- layouts/shortcodes/sc.html --
Inner: {{ .Get 0 }}: {{ len .Inner }}
InnerDeindent: {{ .Get 0 }}: {{ len .InnerDeindent }}
-- layouts/_default/single.html --
{{ .Content }}
`

b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
Running: true,
Verbose: true,
},
).Build()

b.AssertFileContent("public/p1/index.html", `
Inner: self-closing: 0
InnerDeindent: self-closing: 0
Inner: closing-no-newline: 0
InnerDeindent: closing-no-newline: 0
`)
}

0 comments on commit 0dbeac8

Please sign in to comment.