mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
Making partials context optional for compatibility with template.
If not provided, context is nil.
This commit is contained in:
@@ -296,10 +296,17 @@ func NewTemplate() Template {
|
|||||||
return templates
|
return templates
|
||||||
}
|
}
|
||||||
|
|
||||||
func Partial(name string, context interface{}) template.HTML {
|
func Partial(name string, context_list ...interface{}) template.HTML {
|
||||||
if strings.HasPrefix("partials/", name) {
|
if strings.HasPrefix("partials/", name) {
|
||||||
name = name[8:]
|
name = name[8:]
|
||||||
}
|
}
|
||||||
|
var context interface{}
|
||||||
|
|
||||||
|
if len(context_list) == 0 {
|
||||||
|
context = nil
|
||||||
|
} else {
|
||||||
|
context = context_list[0]
|
||||||
|
}
|
||||||
return ExecuteTemplateToHTML(context, "partials/"+name, "theme/partials/"+name)
|
return ExecuteTemplateToHTML(context, "partials/"+name, "theme/partials/"+name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user