From c5642ff5862ac9d720f42d4fa4c418b08578877e Mon Sep 17 00:00:00 2001 From: David Moreau Date: Fri, 5 Nov 2021 11:28:57 +0100 Subject: [PATCH] ReplacePartial --- template.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/template.go b/template.go index f16ed2f..aa199e8 100644 --- a/template.go +++ b/template.go @@ -136,6 +136,14 @@ func (tpl *Template) addPartial(name string, source string, template *Template) tpl.partials[name] = newPartial(name, source, template) } +// ReplacePartial replaces or create a partial +func (tpl *Template) ReplacePartial(name string, source string) { + tpl.mutex.Lock() + defer tpl.mutex.Unlock() + + tpl.partials[name] = newPartial(name, source, nil) +} + func (tpl *Template) findPartial(name string) *partial { tpl.mutex.RLock() defer tpl.mutex.RUnlock()