Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tpl
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-07-03 19:02:32 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-07-04 00:31:51 +0300
commit42e150fbfac736bd49bc7e50cb8cdf9f81386f59 (patch)
treef29afdf089823d6c6d4513ae67934357b88f2a05 /tpl
parent028b356787426dbc190ce9868fbc9a6400c2996e (diff)
Fix server reload when non-HTML shortcode changes
Fixes #7448
Diffstat (limited to 'tpl')
-rw-r--r--tpl/collections/apply_test.go4
-rw-r--r--tpl/template.go1
-rw-r--r--tpl/tplimpl/template.go21
3 files changed, 26 insertions, 0 deletions
diff --git a/tpl/collections/apply_test.go b/tpl/collections/apply_test.go
index 0d06f52e8..f9199b6b6 100644
--- a/tpl/collections/apply_test.go
+++ b/tpl/collections/apply_test.go
@@ -40,6 +40,10 @@ func (templateFinder) LookupVariant(name string, variants tpl.TemplateVariants)
return nil, false, false
}
+func (templateFinder) LookupVariants(name string) []tpl.Template {
+ return nil
+}
+
func (templateFinder) LookupLayout(d output.LayoutDescriptor, f output.Format) (tpl.Template, bool, error) {
return nil, false, nil
}
diff --git a/tpl/template.go b/tpl/template.go
index 315004b6a..82d877545 100644
--- a/tpl/template.go
+++ b/tpl/template.go
@@ -68,6 +68,7 @@ type TemplateLookupVariant interface {
// We are currently only interested in output formats, so we should improve
// this for speed.
LookupVariant(name string, variants TemplateVariants) (Template, bool, bool)
+ LookupVariants(name string) []Template
}
// Template is the common interface between text/template and html/template.
diff --git a/tpl/tplimpl/template.go b/tpl/tplimpl/template.go
index 1243e6a15..6171d167b 100644
--- a/tpl/tplimpl/template.go
+++ b/tpl/tplimpl/template.go
@@ -354,6 +354,23 @@ func (t *templateHandler) LookupVariant(name string, variants tpl.TemplateVarian
}
+// LookupVariants returns all variants of name, nil if none found.
+func (t *templateHandler) LookupVariants(name string) []tpl.Template {
+ name = templateBaseName(templateShortcode, name)
+ s, found := t.shortcodes[name]
+ if !found {
+ return nil
+ }
+
+ variants := make([]tpl.Template, len(s.variants))
+ for i := 0; i < len(variants); i++ {
+ variants[i] = s.variants[i].ts
+ }
+
+ return variants
+
+}
+
func (t *templateHandler) HasTemplate(name string) bool {
if _, found := t.baseof[name]; found {
@@ -966,6 +983,10 @@ func (t *textTemplateWrapperWithLock) LookupVariant(name string, variants tpl.Te
panic("not supported")
}
+func (t *textTemplateWrapperWithLock) LookupVariants(name string) []tpl.Template {
+ panic("not supported")
+}
+
func (t *textTemplateWrapperWithLock) Parse(name, tpl string) (tpl.Template, error) {
t.Lock()
defer t.Unlock()