Summary
XHTML is a critical output from our CMS. Getting down to the details involved in its creation throws up awkward issues. While there are no completely ideal solutions, we have reviewed a variety of approaches. Although it can be interpreted in a variety of ways, the Model-View-Controller pattern incorporates sound ideas.
It is as well not to lose sight of the fact that PHP is itself an excellent templating language, with various means of handling XHTML. For most sections of XHTML, the mechanism I have advocated is the use of heredoc, along with some devices that allow a good deal of flexibility on what can be included into a heredoc.
We have looked at a flexible rendering engine that is complete for pure PHP templates, and can be easily extended to embrace other engines. It is thus possible to build a framework that supports more than one approach to templates.
Some sort of widget-based development has strengths and weaknesses, but is well applied to awkward situations that crop up regularly...