From 31d6dcb656898e5a8f7cd2a216804e1b222b4906 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 29 May 2015 14:06:17 -0700 Subject: [PATCH] template: template path is the directory --- template/interpolate/funcs.go | 3 ++- template/interpolate/funcs_test.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/template/interpolate/funcs.go b/template/interpolate/funcs.go index abe84873f..ba3048823 100644 --- a/template/interpolate/funcs.go +++ b/template/interpolate/funcs.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "os" + "path/filepath" "strconv" "strings" "text/template" @@ -99,7 +100,7 @@ func funcGenTemplatePath(ctx *Context) interface{} { return "", errors.New("template path not available") } - return ctx.TemplatePath, nil + return filepath.Dir(ctx.TemplatePath), nil } } diff --git a/template/interpolate/funcs_test.go b/template/interpolate/funcs_test.go index d6ef3e758..9c7c639f3 100644 --- a/template/interpolate/funcs_test.go +++ b/template/interpolate/funcs_test.go @@ -128,7 +128,7 @@ func TestFuncTemplatePath(t *testing.T) { } ctx := &Context{ - TemplatePath: "foo", + TemplatePath: "foo/bar", } for _, tc := range cases { i := &I{Value: tc.Input}