func (t *Repository) addDependencies(templ *template.Template) (*template.Template, error) { name := templ.Name() deps := t.flattenDependencies(templ, nil) for dep := range deps { if dep == "" { continue } tt := templ.Lookup(dep) // Check if we have it if tt == nil { tt = t.templates[dep] // Still dont have it return an error if tt == nil { return templ, fmt.Errorf("Could not find template %s", dep) } var err error // Add it to the parse tree templ, err = templ.AddParseTree(dep, tt.Tree) if err != nil { return templ, fmt.Errorf("Dependency Error: %v", err) } } } return templ.Lookup(name), nil }