template

William Dode wilk-spamout at flibuste.net
Mon Aug 12 10:23:53 CEST 2002


Hi,

I want to choose the way who will be better for a web designer (using
dreamweaver or something like that...). (maybe i must post on the
newsgroup of design...)

The difference with other template engines is that i don't need to parse
manualy the template each time. I use the parser and the bytecode of
python... The idea is to transform a template in a python script, and so i
just need to import the python script after that.
The transformer is just 20 lines, so i don't loose a lot of time
reinventing the wheel ;)
Also i transform only one time, so the performance of the compiler doesn't
matters.

For example template.html :

<html>
<body>
some texts
<py>
python code
</py>
other texts
</body>
</html>

become a python script template.py :

def run(arg):
    out= """
<html>
<body>
some texts
"""
    python code
    out+= """
other texts
</body>
</html>
"""
    return out

and i just import it and run it :
import template (who become bytecode ;)
template.run(arg) run with arg depends of what i whant to pass...

any comments are welcome !

bye

ps: i use it for CGI scripts

-- 
William Dodé - flibuste.net
http://wikipython.tuxfamily.org



More information about the Python-list mailing list