summaryrefslogtreecommitdiffstats
path: root/hugolib
diff options
context:
space:
mode:
authorCameron Moore <moorereason@gmail.com>2017-03-13 17:55:02 -0500
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-04-30 10:56:38 +0200
commitde7c32a1a880820252e922e0c9fcf69e109c0d1b (patch)
tree07d813f2617dd4a889aaebb885a9c1281a229960 /hugolib
parent154e18ddb9ad205055d5bd4827c87f3f0daf499f (diff)
tpl: Add template function namespaces
This commit moves almost all of the template functions into separate packages under tpl/ and adds a namespace framework. All changes should be backward compatible for end users, as all existing function names in the template funcMap are left intact. Seq and DoArithmatic have been moved out of the helpers package and into template namespaces. Most of the tests involved have been refactored, and many new tests have been written. There's still work to do, but this is a big improvement. I got a little overzealous and added some new functions along the way: - strings.Contains - strings.ContainsAny - strings.HasSuffix - strings.TrimPrefix - strings.TrimSuffix Documentation is forthcoming. Fixes #3042
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/scratch.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/hugolib/scratch.go b/hugolib/scratch.go
index b6a06cd79..4a80416f1 100644
--- a/hugolib/scratch.go
+++ b/hugolib/scratch.go
@@ -14,10 +14,11 @@
package hugolib
import (
- "github.com/spf13/hugo/helpers"
"reflect"
"sort"
"sync"
+
+ "github.com/spf13/hugo/tpl/math"
)
// Scratch is a writable context used for stateful operations in Page/Node rendering.
@@ -49,7 +50,7 @@ func (c *Scratch) Add(key string, newAddend interface{}) (string, error) {
newVal = reflect.Append(addendV, nav).Interface()
}
} else {
- newVal, err = helpers.DoArithmetic(existingAddend, newAddend, '+')
+ newVal, err = math.DoArithmetic(existingAddend, newAddend, '+')
if err != nil {
return "", err
}