Use a plugin (like TS Tidy) or similar.
Any similar plugin will format your HTML when its rendered by the server and before it is sent to the browser. Remove blank lines, indent tags, etc. Most of these plugins, in any engine or language, are based on the venerable HTMLTidy/XMLTidy.