Genshi smells like PHP?
29 January 2007
In Python template engines - why reinvent PHP?, Cliff Wells writes:
Well my point is that template engines such as Genshi, Kid, Myghty, et al all smell of PHP to me. Is some of that just cosmetic? You bet. In fact, probably most of it is just cosmetic. There's no doubt in my mind that Genshi is a powerful too and probably full of beautiful Python code under the hood. That doesn't change how it looks to me from the outside. It isn't Python. I find it mildly ironic that Pythonistas are renowned for their loathing of Perl's typographical perversions and then turn around and create equally ugly things to describe web pages with.
But that has little to do with PHP. Sure, PHP makes you mix code with HTML markup. And most template engines, including Genshi, enable you to add variable substitution and some level of control flow to HTML markup. The problem with PHP, however, is not so much that it allows mixing code and markup, but rather that it uses a document-centric approach where your HTML “templates” drive the application code, and not the other way around. (Plus that PHP is simply a badly designed language.)
Libraries that allow you to generate HTML programmatically—without a single angle bracket in sight—have existed as long as the web itself, but they have been mostly unsuccessful. S-expression style templating as implemented by Stan and now Breve are based on the same basic concept or desire, even though they do use the flexibility and power of Python expressions to provide a more convenient syntax.