mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
tpl: Set Metrics at creation time
This commit is contained in:
parent
d3681f51c0
commit
b5e1dc5892
1 changed files with 5 additions and 13 deletions
|
@ -113,24 +113,16 @@ func (t *templateHandler) Lookup(name string) *tpl.TemplateAdapter {
|
||||||
// The templates are stored without the prefix identificator.
|
// The templates are stored without the prefix identificator.
|
||||||
name = strings.TrimPrefix(name, textTmplNamePrefix)
|
name = strings.TrimPrefix(name, textTmplNamePrefix)
|
||||||
|
|
||||||
te := t.text.Lookup(name)
|
return t.text.Lookup(name)
|
||||||
if te != nil {
|
|
||||||
te.Metrics = t.Deps.Metrics
|
|
||||||
}
|
|
||||||
return te
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look in both
|
// Look in both
|
||||||
if te := t.html.Lookup(name); te != nil {
|
if te := t.html.Lookup(name); te != nil {
|
||||||
te.Metrics = t.Deps.Metrics
|
|
||||||
return te
|
return te
|
||||||
}
|
}
|
||||||
|
|
||||||
te := t.text.Lookup(name)
|
return t.text.Lookup(name)
|
||||||
if te != nil {
|
|
||||||
te.Metrics = t.Deps.Metrics
|
|
||||||
}
|
|
||||||
return te
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *templateHandler) clone(d *deps.Deps) *templateHandler {
|
func (t *templateHandler) clone(d *deps.Deps) *templateHandler {
|
||||||
|
@ -210,7 +202,7 @@ func (t *htmlTemplates) Lookup(name string) *tpl.TemplateAdapter {
|
||||||
if templ == nil {
|
if templ == nil {
|
||||||
return 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 {
|
func (t *htmlTemplates) lookup(name string) *template.Template {
|
||||||
|
@ -250,7 +242,7 @@ func (t *textTemplates) Lookup(name string) *tpl.TemplateAdapter {
|
||||||
if templ == nil {
|
if templ == nil {
|
||||||
return 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 {
|
func (t *textTemplates) lookup(name string) *texttemplate.Template {
|
||||||
|
|
Loading…
Reference in a new issue