It also isn't clear to me what output you expect in all cases. I took some guesses and came up with the following.
Code:
{series}
{series_index:'
test(
field('series'),
cmp($, 0, '', ': ', finish_formatting($, '0>6.1f', '[', ']: ')),
'')
'}
{title}
The template outputs nothing other than the title if there is no series. If there is a series, it outputs only the title if the series index is less than zero, a simple 'colon space' if there is a series but the series index is zero, and [nnnn.n]: if the series index is greater than zero.
Although this template is in
template program mode, I would probably use
general program mode if I were doing it for myself. GPM can be easier to read and debug. For example, the following is equivalent to the above template
Code:
program:
series = field('series');
series_index = field('series_index');
strcat(
series,
test(
series,
cmp(
series_index,
0,
'',
': ',
finish_formatting(series_index, '0>6.1f', '[', ']: ')
),
''
),
field('title')
)