From: Bjørn Erik Pedersen Date: Fri, 3 Apr 2026 14:04:54 +0000 (+0200) Subject: tpl: Fix stray quotes from partial decorator in script context X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=43aad7118da6f8365d9cdb4aaada1878ce68fb98;p=brevno-suite%2Fhugo 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