From 43aad7118da6f8365d9cdb4aaada1878ce68fb98 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 3 Apr 2026 16:04:54 +0200 Subject: [PATCH] tpl: Fix stray quotes from partial decorator in script context Use template.JS for the falsy return value of _PopPartialDecorator so Go's html/template JS escaper doesn't wrap the empty string in quotes inside +` + b := hugolib.Test(t, files) + + b.AssertFileContent("public/index.html", "! \"\"") +} diff --git a/tpl/templates/templates.go b/tpl/templates/templates.go index 77efcdf62..8428ff252 100644 --- a/tpl/templates/templates.go +++ b/tpl/templates/templates.go @@ -17,6 +17,7 @@ package templates import ( "context" "fmt" + htmltemplate "html/template" "strconv" "sync/atomic" @@ -113,7 +114,10 @@ func (ns *Namespace) _PopPartialDecorator(ctx context.Context, id string) any { } if !top.Bool { // Prevents anything being rendered if inner was not called. - return "" + // Use template.JS to avoid Go's html/template JS escaper + // wrapping an empty string in quotes inside