summaryrefslogtreecommitdiff
path: root/parse.go
diff options
context:
space:
mode:
Diffstat (limited to 'parse.go')
-rw-r--r--parse.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/parse.go b/parse.go
index d087e95..15c5877 100644
--- a/parse.go
+++ b/parse.go
@@ -8,8 +8,10 @@ import (
"io"
"net"
"os/user"
+ "path/filepath"
"strconv"
"strings"
+ "text/template"
"github.com/go-kit/log/level"
"tildegit.org/tjp/sliderule/gemini"
@@ -448,12 +450,36 @@ func parseModifiers(text string) (Modifiers, string, error) {
mod.titanName = text[0:idx]
text = text[idx+1:]
}
+ case "templates":
+ if sep != " " {
+ return mod, "", errors.New("invalid 'templates' clause")
+ }
+ text = strings.TrimLeft(text, " \t")
+ idx = strings.IndexAny(text, " \t,")
+ var err error
+ if idx == 0 {
+ return mod, "", errors.New("invalid 'templates' clause")
+ } else if idx < 0 {
+ mod.Templates, err = loadTemplates(text)
+ text = ""
+ } else {
+ mod.Templates, err = loadTemplates(text[0:idx])
+ text = text[idx+1:]
+ }
+
+ if err != nil {
+ return mod, "", err
+ }
default:
return mod, text, nil
}
}
}
+func loadTemplates(dirpath string) (*template.Template, error) {
+ return template.ParseGlob(filepath.Join(dirpath, "*"))
+}
+
func parseAuth(text string) (string, string, error) {
spl := strings.SplitN(text, " ", 2)
switch len(spl) {