tpl: Add missing functions to init files

Closes #14249
This commit is contained in:
Joe Mooring
2025-12-13 09:32:26 -08:00
committed by GitHub
parent fae49a22f1
commit fa7d37f0c8
24 changed files with 873 additions and 429 deletions
+69 -54
View File
@@ -38,28 +38,6 @@ func init() {
},
)
ns.AddMethodMapping(ctx.CountRunes,
[]string{"countrunes"},
[][2]string{},
)
ns.AddMethodMapping(ctx.RuneCount,
nil,
[][2]string{},
)
ns.AddMethodMapping(ctx.CountWords,
[]string{"countwords"},
[][2]string{},
)
ns.AddMethodMapping(ctx.Count,
nil,
[][2]string{
{`{{ "aabab" | strings.Count "a" }}`, `3`},
},
)
ns.AddMethodMapping(ctx.Contains,
nil,
[][2]string{
@@ -76,6 +54,33 @@ func init() {
},
)
ns.AddMethodMapping(ctx.ContainsNonSpace,
nil,
[][2]string{},
)
ns.AddMethodMapping(ctx.Count,
nil,
[][2]string{
{`{{ "aabab" | strings.Count "a" }}`, `3`},
},
)
ns.AddMethodMapping(ctx.CountRunes,
[]string{"countrunes"},
[][2]string{},
)
ns.AddMethodMapping(ctx.CountWords,
[]string{"countwords"},
[][2]string{},
)
ns.AddMethodMapping(ctx.Diff,
nil,
[][2]string{},
)
ns.AddMethodMapping(ctx.FindRE,
[]string{"findRE"},
[][2]string{
@@ -96,6 +101,13 @@ func init() {
},
)
ns.AddMethodMapping(ctx.FirstUpper,
nil,
[][2]string{
{`{{ "hugo rocks!" | strings.FirstUpper }}`, `Hugo rocks!`},
},
)
ns.AddMethodMapping(ctx.HasPrefix,
[]string{"hasPrefix"},
[][2]string{
@@ -112,10 +124,10 @@ func init() {
},
)
ns.AddMethodMapping(ctx.ToLower,
[]string{"lower"},
ns.AddMethodMapping(ctx.Repeat,
nil,
[][2]string{
{`{{ lower "BatMan" }}`, `batman`},
{`{{ "yo" | strings.Repeat 4 }}`, `yoyoyoyo`},
},
)
@@ -147,6 +159,11 @@ func init() {
},
)
ns.AddMethodMapping(ctx.RuneCount,
nil,
[][2]string{},
)
ns.AddMethodMapping(ctx.SliceString,
[]string{"slicestr"},
[][2]string{
@@ -168,6 +185,28 @@ func init() {
},
)
ns.AddMethodMapping(ctx.Title,
[]string{"title"},
[][2]string{
{`{{ title "Bat man" }}`, `Bat Man`},
{`{{ title "somewhere over the rainbow" }}`, `Somewhere Over the Rainbow`},
},
)
ns.AddMethodMapping(ctx.ToLower,
[]string{"lower"},
[][2]string{
{`{{ lower "BatMan" }}`, `batman`},
},
)
ns.AddMethodMapping(ctx.ToUpper,
[]string{"upper"},
[][2]string{
{`{{ upper "BatMan" }}`, `BATMAN`},
},
)
ns.AddMethodMapping(ctx.Trim,
[]string{"trim"},
[][2]string{
@@ -197,6 +236,11 @@ func init() {
},
)
ns.AddMethodMapping(ctx.TrimSpace,
nil,
[][2]string{},
)
ns.AddMethodMapping(ctx.TrimSuffix,
nil,
[][2]string{
@@ -205,21 +249,6 @@ func init() {
},
)
ns.AddMethodMapping(ctx.Title,
[]string{"title"},
[][2]string{
{`{{ title "Bat man" }}`, `Bat Man`},
{`{{ title "somewhere over the rainbow" }}`, `Somewhere Over the Rainbow`},
},
)
ns.AddMethodMapping(ctx.FirstUpper,
nil,
[][2]string{
{`{{ "hugo rocks!" | strings.FirstUpper }}`, `Hugo rocks!`},
},
)
ns.AddMethodMapping(ctx.Truncate,
[]string{"truncate"},
[][2]string{
@@ -228,20 +257,6 @@ func init() {
},
)
ns.AddMethodMapping(ctx.Repeat,
nil,
[][2]string{
{`{{ "yo" | strings.Repeat 4 }}`, `yoyoyoyo`},
},
)
ns.AddMethodMapping(ctx.ToUpper,
[]string{"upper"},
[][2]string{
{`{{ upper "BatMan" }}`, `BATMAN`},
},
)
return ns
}