I'm doing something very similar; I'm on a large Perl project that I'm trying to make intelligible. I'd add the following pieces of advice:
- Write automated unit tests. (See Test and Refactoring.) Run them frequently.
- Don't try to put all of the HTML into templates in one gigantic effort. Work a bit at a time, interspersing your refactoring efforts with adding new features to keep your managers happy.
- Make sure that you get buy-in from your fellow developers. It does little good for you to be fixing old code when new code is being written with embedded HTML.
- Write automated unit tests. Run them frequently. (Okay, but it's important!)
stephen