Pht has an elegant syntax and integrates quite nicely a structured procedural language with a descriptive language, combining the block structures of both, providing a clear and consistent view of them. It allows for far more checking of the output than the standard way of running the program and checking a sample output. As it curently stands, a couple of IDEs and editors I tried manage to format the Pht source files properly, matching the curly braces correctly, which already goes a long way into validating the code.  Also, I cannot forget to quote the value of attributes, since the compiler takes care of that, nor of escaping the data or ensuring the tags are eventually closed.  Basically, I can visually check a lot of the code right in the IDE and by the time I successfully pre-compile the source it is quite close to generate valid XML.

If it could be integrated with the base language interpreter (PHP in this case) more intimately, the possibilities of error checking and optimization would be far better. Though for HTML output, the use of template engines is by far the most popular way, with plenty of reasons for that preference, Pht or any of its siblings is mostly meant for XML services and other XML-based template engines, such as XSLT could provide and, anyhow, at some point or another, some XML/HTML has to be output, even a template engine has to do that.

And, finally, as I said, the same principles can be applied to many languages. The symbols might have to be changed and some languages might be harder to analyze, but it shouldn't be impossible.

< Previous: Validation