remove trailing spaces in templates