mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
Allow the same shortcode to be used with or without inline content
Fixes #934
This commit is contained in:
@@ -184,6 +184,9 @@ func TestExtractShortcodes(t *testing.T) {
|
||||
testScPlaceholderRegexp, ""},
|
||||
{"inner", `Some text. {{< inner >}}Inner Content{{< / inner >}}. Some more text.`, `inner([], false){[Inner Content]}`,
|
||||
fmt.Sprintf("Some text. %s. Some more text.", testScPlaceholderRegexp), ""},
|
||||
// issue #934
|
||||
{"inner self-closing", `Some text. {{< inner />}}. Some more text.`, `inner([], false){[]}`,
|
||||
fmt.Sprintf("Some text. %s. Some more text.", testScPlaceholderRegexp), ""},
|
||||
{"close, but not inner", "{{< tag >}}foo{{< /tag >}}", "", false, "Shortcode 'tag' in page 'simple.md' has no .Inner.*"},
|
||||
{"nested inner", `Inner->{{< inner >}}Inner Content->{{% inner2 param1 %}}inner2txt{{% /inner2 %}}Inner close->{{< / inner >}}<-done`,
|
||||
`inner([], false){[Inner Content-> inner2([\"param1\"], true){[inner2txt]} Inner close->]}`,
|
||||
@@ -212,7 +215,7 @@ func TestExtractShortcodes(t *testing.T) {
|
||||
tem.AddInternalShortcode("tag.html", `tag`)
|
||||
tem.AddInternalShortcode("sc1.html", `sc1`)
|
||||
tem.AddInternalShortcode("sc2.html", `sc2`)
|
||||
tem.AddInternalShortcode("inner.html", `{{.Inner}}`)
|
||||
tem.AddInternalShortcode("inner.html", `{{with .Inner }}{{ . }}{{ end }}`)
|
||||
tem.AddInternalShortcode("inner2.html", `{{.Inner}}`)
|
||||
tem.AddInternalShortcode("inner3.html", `{{.Inner}}`)
|
||||
|
||||
|
Reference in New Issue
Block a user