Commit 43a6bcff authored by Fabian Ruff's avatar Fabian Ruff

Add .Template.BasePath to template system

parent 0861b5e3
...@@ -120,6 +120,8 @@ type renderable struct { ...@@ -120,6 +120,8 @@ type renderable struct {
tpl string tpl string
// vals are the values to be supplied to the template. // vals are the values to be supplied to the template.
vals chartutil.Values vals chartutil.Values
// namespace prefix to the templates of the current chart
basePath string
} }
// alterFuncMap takes the Engine's FuncMap and adds context-specific functions. // alterFuncMap takes the Engine's FuncMap and adds context-specific functions.
...@@ -178,7 +180,7 @@ func (e *Engine) render(tpls map[string]renderable) (map[string]string, error) { ...@@ -178,7 +180,7 @@ func (e *Engine) render(tpls map[string]renderable) (map[string]string, error) {
for _, file := range files { for _, file := range files {
// At render time, add information about the template that is being rendered. // At render time, add information about the template that is being rendered.
vals := tpls[file].vals vals := tpls[file].vals
vals["Template"] = map[string]interface{}{"Name": file} vals["Template"] = map[string]interface{}{"Name": file, "BasePath": tpls[file].basePath}
if err := t.ExecuteTemplate(&buf, file, vals); err != nil { if err := t.ExecuteTemplate(&buf, file, vals); err != nil {
return map[string]string{}, fmt.Errorf("render error in %q: %s", file, err) return map[string]string{}, fmt.Errorf("render error in %q: %s", file, err)
} }
...@@ -246,8 +248,9 @@ func recAllTpls(c *chart.Chart, templates map[string]renderable, parentVals char ...@@ -246,8 +248,9 @@ func recAllTpls(c *chart.Chart, templates map[string]renderable, parentVals char
} }
for _, t := range c.Templates { for _, t := range c.Templates {
templates[path.Join(newParentID, t.Name)] = renderable{ templates[path.Join(newParentID, t.Name)] = renderable{
tpl: string(t.Data), tpl: string(t.Data),
vals: cvals, vals: cvals,
basePath: path.Join(newParentID, "templates"),
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment