diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-09-26 20:42:40 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-09-26 20:42:40 +0200 |
commit | b5e1dc5892f81da798d0d4e964a1f3328532f45e (patch) | |
tree | e0c7a7103c3c7c6ded288bd296e1bd5b29a49511 /tpl/tplimpl | |
parent | d3681f51c08fb11e8addcf9f0b484848d20d46cc (diff) |
tpl: Set Metrics at creation time
Diffstat (limited to 'tpl/tplimpl')
-rw-r--r-- | tpl/tplimpl/template.go | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/tpl/tplimpl/template.go b/tpl/tplimpl/template.go index f25ff8909..46484ed83 100644 --- a/tpl/tplimpl/template.go +++ b/tpl/tplimpl/template.go @@ -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 { @@ -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 { @@ -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 { |