Simplify variable expansion in template

Instead of allocating a temporary variable just to free it right after
copying it to the string buffer, append it directly from the converter
functions.  Should avoid a bunch of unneeded memory allocations.