From: spf13 Date: Wed, 3 Sep 2014 15:30:08 +0000 (-0400) Subject: Making partials context optional for compatibility with template. X-Git-Tag: v0.13~429 X-Git-Url: http://git.maquefel.me//?a=commitdiff_plain;h=1b7f18e39172429545198b3559dcc64bbfb7aa9c;p=brevno-suite%2Fhugo Making partials context optional for compatibility with template. If not provided, context is nil. --- diff --git a/hugolib/template.go b/hugolib/template.go index 23cb7a68..c9f62a99 100644 --- a/hugolib/template.go +++ b/hugolib/template.go @@ -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) }