Move format string function into template-utils