while loop out of template