From 1b7f18e39172429545198b3559dcc64bbfb7aa9c Mon Sep 17 00:00:00 2001 From: spf13 Date: Wed, 3 Sep 2014 11:30:08 -0400 Subject: [PATCH] Making partials context optional for compatibility with template. If not provided, context is nil. --- hugolib/template.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hugolib/template.go b/hugolib/template.go index 23cb7a680..c9f62a99e 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) }