tpl: Fix substr when length parameter is zero

When length parameter is zero, always return an empty string.

Updates #7993
This commit is contained in:
Cameron Moore
2020-11-28 09:56:49 -06:00
committed by Bjørn Erik Pedersen
parent 64789fb5dc
commit 5862fd2a60
2 changed files with 9 additions and 3 deletions

View File

@@ -327,9 +327,12 @@ func (ns *Namespace) Substr(a interface{}, nums ...interface{}) (string, error)
end := rlen
if length < 0 {
switch {
case length == 0:
return "", nil
case length < 0:
end += length
} else if length > 0 {
case length > 0:
end = start + length
}