Skip to content

Commit

Permalink
tpl: Set Metrics at creation time
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Sep 26, 2017
1 parent d3681f5 commit b5e1dc5
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions tpl/tplimpl/template.go
Expand Up @@ -113,24 +113,16 @@ func (t *templateHandler) Lookup(name string) *tpl.TemplateAdapter {
// The templates are stored without the prefix identificator.
name = strings.TrimPrefix(name, textTmplNamePrefix)

te := t.text.Lookup(name)
if te != nil {
te.Metrics = t.Deps.Metrics
}
return te
return t.text.Lookup(name)
}

// Look in both
if te := t.html.Lookup(name); te != nil {
te.Metrics = t.Deps.Metrics
return te
}

te := t.text.Lookup(name)
if te != nil {
te.Metrics = t.Deps.Metrics
}
return te
return t.text.Lookup(name)

}

func (t *templateHandler) clone(d *deps.Deps) *templateHandler {
Expand Down Expand Up @@ -210,7 +202,7 @@ func (t *htmlTemplates) Lookup(name string) *tpl.TemplateAdapter {
if templ == nil {
return nil
}
return &tpl.TemplateAdapter{Template: templ}
return &tpl.TemplateAdapter{Template: templ, Metrics: t.funcster.Deps.Metrics}
}

func (t *htmlTemplates) lookup(name string) *template.Template {
Expand Down Expand Up @@ -250,7 +242,7 @@ func (t *textTemplates) Lookup(name string) *tpl.TemplateAdapter {
if templ == nil {
return nil
}
return &tpl.TemplateAdapter{Template: templ}
return &tpl.TemplateAdapter{Template: templ, Metrics: t.funcster.Deps.Metrics}
}

func (t *textTemplates) lookup(name string) *texttemplate.Template {
Expand Down

0 comments on commit b5e1dc5

Please sign in to comment.