mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 15:28:54 +00:00
Making partials context optional for compatibility with template.
If not provided, context is nil.
This commit is contained in:
+8
-1
@@ -296,10 +296,17 @@ func NewTemplate() Template {
|
||||
return templates
|
||||
}
|
||||
|
||||
func Partial(name string, context interface{}) template.HTML {
|
||||
func Partial(name string, context_list ...interface{}) template.HTML {
|
||||
if strings.HasPrefix("partials/", name) {
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user