.Get doesn't crash on missing positional param

fixes #4619
This commit is contained in:
cmal 2018-04-17 11:24:03 +02:00 committed by Bjørn Erik Pedersen
parent cd6a261242
commit 236f0c840b

View file

@ -86,8 +86,7 @@ func (scp *ShortcodeWithPage) Get(key interface{}) interface{} {
idx := int(reflect.ValueOf(key).Int()) idx := int(reflect.ValueOf(key).Int())
ln := reflect.ValueOf(scp.Params).Len() ln := reflect.ValueOf(scp.Params).Len()
if idx > ln-1 { if idx > ln-1 {
helpers.DistinctErrorLog.Printf("No shortcode param at .Get %d in page %s, have params: %v", idx, scp.Page.FullFilePath(), scp.Params) return ""
return fmt.Sprintf("error: index out of range for positional param at position %d", idx)
} }
x = reflect.ValueOf(scp.Params).Index(idx) x = reflect.ValueOf(scp.Params).Index(idx)
} }