tpl: Do not return errors in substr for out-of-bounds cases
authorCameron Moore <moorereason@gmail.com>
Sun, 3 Jan 2021 18:01:42 +0000 (12:01 -0600)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 8 Jan 2021 09:13:10 +0000 (10:13 +0100)
commit8a26ab0bc5dd9fa34e1362681fc08b0e522cd4ea
tree40b069293d1edff1ae47bcb6885af3dd3734c7df
parent788e50ad3a55609ed49ce0b7ee98965c181fe9cf
tpl: Do not return errors in substr for out-of-bounds cases

Most other substr implementations don't error out in out-of-bounds cases
but simply return an empty string (or a value that's printed as an empty
string). We'll follow their lead and not exit template execution.  Allow
the user decide what to do with the empty result.

Fixes #8113
tpl/strings/strings.go
tpl/strings/strings_test.go