Parse reference templates in predictable order

Fix issue #7701

Signed-off-by: Andre Sencioles <asenci@gmail.com>
pull/7702/head
Andre Sencioles 6 years ago
parent 53b6580bad
commit 96e809dfe7

@ -213,6 +213,7 @@ func (e Engine) renderWithReferences(tpls, referenceTpls map[string]renderable)
// We want to parse the templates in a predictable order. The order favors
// higher-level (in file system) templates over deeply nested templates.
keys := sortTemplates(tpls)
referenceKeys := sortTemplates(referenceTpls)
for _, filename := range keys {
r := tpls[filename]
@ -223,8 +224,9 @@ func (e Engine) renderWithReferences(tpls, referenceTpls map[string]renderable)
// Adding the reference templates to the template context
// so they can be referenced in the tpl function
for filename, r := range referenceTpls {
for _, filename := range referenceKeys {
if t.Lookup(filename) == nil {
r := referenceTpls[filename]
if _, err := t.New(filename).Parse(r.tpl); err != nil {
return map[string]string{}, cleanupParseError(filename, err)
}

Loading…
Cancel
Save