Making partials context optional for compatibility with template.

If not provided, context is nil.
This commit is contained in:
spf13 2014-09-03 11:30:08 -04:00
parent 7b3df2386d
commit 1b7f18e391

View file

@ -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)
}