Remove unnecessary spaces for template.