From 0d7698b57c007ca339329798d17c2a678f3d90df Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Sat, 20 Jan 2018 12:06:46 -0500 Subject: [PATCH] contentFor behavior changed fixes #39 --- content_helper.go | 2 +- context.go | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/content_helper.go b/content_helper.go index d1fdb82..a805ea8 100644 --- a/content_helper.go +++ b/content_helper.go @@ -8,7 +8,7 @@ import ( // ContentFor stores a block of templating code to be re-used later in the template. /* - <%= contentFor("buttons") { %> + <% contentFor("buttons") { %> <% } %> */ diff --git a/context.go b/context.go index 21209c8..eed5172 100644 --- a/context.go +++ b/context.go @@ -73,17 +73,16 @@ func NewContext() *Context { func NewContextWith(data map[string]interface{}) *Context { c := &Context{ Context: context.Background(), - data: map[string]interface{}{}, + data: data, outer: nil, moot: &sync.Mutex{}, } for k, v := range Helpers.helpers { - c.Set(k, v) + if !c.Has(k) { + c.Set(k, v) + } } - for k, v := range data { - c.Set(k, v) - } return c }