Skip to content

Commit 89b2214

Browse files
committed
fix: ensure jet bindings use non-nil context
1 parent 05b6534 commit 89b2214

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

jet/jet.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,15 @@ func (e *Engine) Render(out io.Writer, name string, binding interface{}, layout
191191

192192
func jetVarMap(binding interface{}) jet.VarMap {
193193
if binding == nil {
194-
return nil
194+
return make(jet.VarMap)
195195
}
196196

197197
if bind, ok := binding.(jet.VarMap); ok {
198198
return bind
199199
}
200200

201201
data := core.AcquireViewContext(binding)
202-
bind := make(jet.VarMap)
202+
bind := make(jet.VarMap, len(data))
203203
for key, value := range data {
204204
bind.Set(key, value)
205205
}

template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func AcquireViewContext(binding interface{}) map[string]interface{} {
144144
}
145145

146146
val := reflect.ValueOf(binding)
147-
if val.Kind() == reflect.Pointer {
147+
if val.Kind() == reflect.Ptr {
148148
if val.IsNil() {
149149
return make(map[string]interface{})
150150
}

0 commit comments

Comments
 (0)