rearrange template tostring logic to accomodate rendering template in memory