summaryrefslogtreecommitdiff
path: root/context.go
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2019-11-11 16:03:16 -0500
committerDave Henderson <dhenderson@gmail.com>2020-05-03 22:12:08 -0400
commit7ff174a86a935191a684f0c63f9e2a48058fabfb (patch)
tree00f59ab63d0e581d821307df57abd5cb6f2986c0 /context.go
parent8c8287777495dbb1e2b24e570db0bd504bf18372 (diff)
Support a config file to use instead of commandline arguments
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'context.go')
-rw-r--r--context.go17
1 files changed, 4 insertions, 13 deletions
diff --git a/context.go b/context.go
index ab12d404..a2b8b002 100644
--- a/context.go
+++ b/context.go
@@ -1,10 +1,12 @@
package gomplate
import (
+ "context"
"os"
"strings"
"github.com/hairyhenderson/gomplate/v3/data"
+ "github.com/hairyhenderson/gomplate/v3/internal/config"
)
// context for templates
@@ -20,11 +22,10 @@ func (c *tmplctx) Env() map[string]string {
return env
}
-func createTmplContext(contexts []string, d *data.Data) (interface{}, error) {
+func createTmplContext(ctx context.Context, contexts config.DSources, d *data.Data) (interface{}, error) {
var err error
tctx := &tmplctx{}
- for _, c := range contexts {
- a := parseAlias(c)
+ for a := range contexts {
if a == "." {
return d.Datasource(a)
}
@@ -35,13 +36,3 @@ func createTmplContext(contexts []string, d *data.Data) (interface{}, error) {
}
return tctx, nil
}
-
-func parseAlias(arg string) string {
- parts := strings.SplitN(arg, "=", 2)
- switch len(parts) {
- case 1:
- return strings.SplitN(parts[0], ".", 2)[0]
- default:
- return parts[0]
- }
-}