I was asked to write a custom template for a wordpress based site, and I'm noticing that themes are usually one big unreadable mess of PHP code mixed with HTML, with a terrible indenting on top of it -- even the default template follows this style.
What I'm doing now is put all the PHP code first, then the markup with minimum PHP just for control structures and variables -- kind of what you'd do in a controller <-> view system, only in the same file.
What's a good approach people use to write templates while keeping logic code separate from markup? It's a moderately high traffic site, so I'd like to keep unnecessary overhead to a minimum.