mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Making partials context optional for compatibility with template.
If not provided, context is nil.
This commit is contained in:
parent
7b3df2386d
commit
1b7f18e391
1 changed files with 8 additions and 1 deletions
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue