variant = `{{ template "_internal/pagination.html" (dict "page" . "format" "terse") }}`
test(variant, expectedOutputTerseFormat)
}
+
+func TestOpengraphPartialIssue14433(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+baseURL = "https://example.org"
+-- content/_index.md --
+---
+title: Home
+---
+-- layouts/home.html --
+<!DOCTYPE html>
+<html lang="en">
+<head>
+{{- partial "opengraph.html" . }}
+</head>
+<body>
+</body>
+</html>
+`
+ b := Test(t, files)
+
+ b.AssertFileContent("public/index.html",
+ `<meta property="og:title" content="Home">`,
+ `! false`,
+ )
+}
}
// For internal use only.
-func (ns *Namespace) _PopPartialDecorator(ctx context.Context, id string) bool {
+func (ns *Namespace) _PopPartialDecorator(ctx context.Context, id string) any {
stack := tpl.Context.PartialDecoratorIDStack.Get(ctx)
if stack == nil || stack.Len() == 0 {
panic("decorator stack is nil or empty")
if !ok || top.Str != id {
panic("partial decorator ID mismatch")
}
+ if !top.Bool {
+ // Prevents anything being rendered if inner was not called.
+ return ""
+ }
return top.Bool // return whether inner exists in the wrapped partial.
}