mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 15:28:54 +00:00
tpl/tplimpl: Make template name lookup case-insensitive
Closes #15057 Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
790a8aa474
commit
e46d37a984
@@ -14,6 +14,8 @@
|
||||
package tplimpl
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/gohugoio/hugo/common/types"
|
||||
"github.com/gohugoio/hugo/hugolib/sitesmatrix"
|
||||
"github.com/gohugoio/hugo/resources/kinds"
|
||||
@@ -44,6 +46,8 @@ type TemplateDescriptor struct {
|
||||
}
|
||||
|
||||
func (d *TemplateDescriptor) normalizeFromFile() {
|
||||
d.LayoutFromTemplate = strings.ToLower(d.LayoutFromTemplate)
|
||||
|
||||
if d.LayoutFromTemplate == d.OutputFormat {
|
||||
d.LayoutFromTemplate = ""
|
||||
}
|
||||
@@ -138,7 +142,7 @@ func (this TemplateDescriptor) doCompare(category Category, other TemplateDescri
|
||||
// when one exist for the html output format (same media type).
|
||||
skip := category != CategoryBaseof && (this.Kind == "" || (this.Kind != other.Kind && (this.LayoutFromTemplate != other.LayoutFromTemplate && other.LayoutFromTemplate != layoutAll)))
|
||||
if this.LayoutFromUser != "" {
|
||||
skip = skip && (this.LayoutFromUser != other.LayoutFromTemplate)
|
||||
skip = skip && this.LayoutFromUser != other.LayoutFromTemplate
|
||||
}
|
||||
if skip {
|
||||
return w
|
||||
|
||||
@@ -425,6 +425,7 @@ func (q *TemplateQuery) init() {
|
||||
}
|
||||
|
||||
q.Name = strings.ToLower(q.Name)
|
||||
q.Desc.LayoutFromUser = strings.ToLower(q.Desc.LayoutFromUser)
|
||||
|
||||
if q.Category == 0 {
|
||||
panic("category not set")
|
||||
|
||||
Reference in New Issue
Block a user