aboutsummaryrefslogtreecommitdiff
path: root/page/page.go
diff options
context:
space:
mode:
Diffstat (limited to 'page/page.go')
-rw-r--r--page/page.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/page/page.go b/page/page.go
index 29b35bc..214021e 100644
--- a/page/page.go
+++ b/page/page.go
@@ -33,6 +33,8 @@ import (
"log"
"os"
"path/filepath"
+ "regexp"
+ "strings"
"text/template"
"github.com/russross/blackfriday"
@@ -67,7 +69,22 @@ type Page struct {
var Global interface{}
// Funcs accessible to the templates.
-var Funcs template.FuncMap
+var Funcs template.FuncMap = template.FuncMap{
+ "join": strings.Join,
+ "split": strings.Split,
+ "toLower": strings.ToLower,
+ "toUpper": strings.ToUpper,
+ "replace": strings.Replace,
+ "replaceAll": strings.ReplaceAll,
+ "toTitle": strings.ToTitle,
+ "hasPrefix": strings.HasPrefix,
+ "hasSuffix": strings.HasSuffix,
+ "trimPrefix": strings.TrimPrefix,
+ "trimSuffix": strings.TrimSuffix,
+ "regexpReplaceAll": func(s, regex, rep string) string {
+ return regexp.MustCompile(regex).ReplaceAllString(s, rep)
+ },
+}
// CacheIndex determines whether or not the index will be cached in memory
// or rebuilt on each call.