From 80f05953111ee750e652c30d40b5c64e6d6815dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Mon, 5 May 2025 10:11:28 +0200 Subject: [PATCH] tpl: Fix case issue in templates.Exists Fixes #13684 --- tpl/templates/templates_integration_test.go | 16 ++++++++++++++++ tpl/tplimpl/templatestore.go | 1 + 2 files changed, 17 insertions(+) diff --git a/tpl/templates/templates_integration_test.go b/tpl/templates/templates_integration_test.go index d16333ed4..baa917eee 100644 --- a/tpl/templates/templates_integration_test.go +++ b/tpl/templates/templates_integration_test.go @@ -299,3 +299,19 @@ P2. b := hugolib.Test(t, files) b.AssertFileContent("public/index.html", "P1: P1.\nP2: foo bar") } + +func TestTemplateExistsCaseIssue13684(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +-- layouts/home.html -- +P1: {{ templates.Exists "_partials/MyPartial.html" }}|P1: {{ templates.Exists "_partials/mypartial.html" }}| +-- layouts/_partials/MyPartial.html -- +MyPartial. + +` + + b := hugolib.Test(t, files) + b.AssertFileContent("public/index.html", "P1: true|P1: true|") +} diff --git a/tpl/tplimpl/templatestore.go b/tpl/tplimpl/templatestore.go index 4adf76b29..53880eb33 100644 --- a/tpl/tplimpl/templatestore.go +++ b/tpl/tplimpl/templatestore.go @@ -712,6 +712,7 @@ func (s *TemplateStore) RefreshFiles(include func(fi hugofs.FileMetaInfo) bool) } func (s *TemplateStore) HasTemplate(templatePath string) bool { + templatePath = strings.ToLower(templatePath) templatePath = paths.AddLeadingSlash(templatePath) return s.templatesByPath.Contains(templatePath) }