modified template tostring method to accommodate rendering in memory