Make sure that a template expansion ends with a ']'.
{{{
[template foo 1]
[fool]
}}}
was generating `1[fool]` - the template would be expanded but then when it
didn't match the `]` it would fail and just get copied to the output. This
change checks for `]` before expanding the template. So it now generates
`[fool]` which is an improvement.
I'm not including a version switch as I see this as a plain bug fix - I can't
imagine this change ever being anything but beneficial.
[SVN r54816]