mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-31 22:41:53 +02:00
all: Run modernize -fix ./...
This commit is contained in:
@@ -431,7 +431,7 @@ func (t *templateHandler) LookupVariants(name string) []tpl.Template {
|
||||
}
|
||||
|
||||
variants := make([]tpl.Template, len(s.variants))
|
||||
for i := 0; i < len(variants); i++ {
|
||||
for i := range variants {
|
||||
variants[i] = s.variants[i].ts
|
||||
}
|
||||
|
||||
@@ -599,7 +599,7 @@ func (t *templateHandler) addFileContext(templ tpl.Template, inerr error) error
|
||||
func (t *templateHandler) extractIdentifiers(line string) []string {
|
||||
m := identifiersRe.FindAllStringSubmatch(line, -1)
|
||||
identifiers := make([]string, len(m))
|
||||
for i := 0; i < len(m); i++ {
|
||||
for i := range m {
|
||||
identifiers[i] = m[i][1]
|
||||
}
|
||||
return identifiers
|
||||
|
@@ -27,6 +27,7 @@ import (
|
||||
"github.com/gohugoio/hugo/common/maps"
|
||||
"github.com/gohugoio/hugo/tpl"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"slices"
|
||||
)
|
||||
|
||||
type templateType int
|
||||
@@ -187,7 +188,7 @@ func (c *templateContext) applyTransformations(n parse.Node) (bool, error) {
|
||||
for i, cmd := range x.Cmds {
|
||||
keep, _ := c.applyTransformations(cmd)
|
||||
if !keep {
|
||||
x.Cmds = append(x.Cmds[:i], x.Cmds[i+1:]...)
|
||||
x.Cmds = slices.Delete(x.Cmds, i, i+1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,12 +272,7 @@ func (c *templateContext) applyTransformationsToNodes(nodes ...parse.Node) {
|
||||
}
|
||||
|
||||
func (c *templateContext) hasIdent(idents []string, ident string) bool {
|
||||
for _, id := range idents {
|
||||
if id == ident {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(idents, ident)
|
||||
}
|
||||
|
||||
// collectConfig collects and parses any leading template config variable declaration.
|
||||
|
@@ -64,6 +64,7 @@ import (
|
||||
_ "github.com/gohugoio/hugo/tpl/time"
|
||||
_ "github.com/gohugoio/hugo/tpl/transform"
|
||||
_ "github.com/gohugoio/hugo/tpl/urls"
|
||||
maps0 "maps"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -290,9 +291,7 @@ func createFuncMap(d *deps.Deps) map[string]any {
|
||||
}
|
||||
|
||||
if d.OverloadedTemplateFuncs != nil {
|
||||
for k, v := range d.OverloadedTemplateFuncs {
|
||||
funcMap[k] = v
|
||||
}
|
||||
maps0.Copy(funcMap, d.OverloadedTemplateFuncs)
|
||||
}
|
||||
|
||||
d.TmplFuncMap = funcMap
|
||||
|
Reference in New Issue
Block a user