My search for a html library like phphtmllib in python yield some better results compared to the past time. I thought I’d still used the same keyword. This is a little bit about phphtmllib:-
A set of PHP classes and library functions to help facilitate building, debugging, and rendering of XML, HTML, XHTML, WAP/WML Documents, and SVG (Scalable Vector Graphics) images as well as complex html ‘widgets’.
Some simple usage:-
$page = new HTMLPageClass('Hello')
$page->add(html_h1('hello world'))
print $page->render()
It means we can produced HTML directly from php, OO fashion and nicely indented output. All HTML tag were php objects and it also provide a list of helper function that returns the php objects, such $p = html_h1() is similar to $p = new HTMLTagH1. That just for illustration, I’d forgot the exact class name. While at my previous job, we heavily used this library in our application and it proves to be powerfull and flexible approach especially when dealing with a very complex forms. We also use template before that, so we know the difference between both approach. Nuff said about that.
Now I want the same thing in python. The closest one is HTMLgen but it’s not maintained anymore. Look’s like the python community not really interested in a library like this. Probably they have some better ways but I love this approach. So, when I searched about it again, I found these two library:-
- pyhtmloo - http://pyhtmloo.sourceforge.net/
- pyweb - http://www.freenet.org.nz/python/pyweb/
The author of pyhtmloo even mentioned that he was inspired by phphtmllib. The sad part is both were not actively developed anymore based on the recent release which was in 2003. So if any of you (who read this) knows something about the existence of such library in python, I beg you, please let me know. Just don’t let me port phphtmllib to python. The desire is height, I just need to learn python :-)
Update
Stan from Nevow projects look’s interesting. It’s just based on reading this article:- http://www.kieranholland.com/prose/meet-stan/
damn … I’d even forgot to put semi-colon at the end of my php script ;-)
