Python embedded like PHP

robin at execulink.com robin at execulink.com
Wed Mar 20 14:16:15 EST 2002


I'm not at all fond of mixing up HTML and code. For real-world sites
that are not trivially small, this presents a growing maintenance
problem.

Much better, IMO, to keep all of the python code in modules, where it
belongs, and have an simple syntax for mixing the results of executing
code in with a web page. That way the HTML people can do their thing,
and the coders theirs. 

My Wasp templating system does this. Pages look like the following:

=====

<?w include:header('Example page') ?>
<?w execute:banner() ?>

<p>A sample page using Wasp. HTML where HTML belongs; code where code
belongs.</p>

<?w include:footer() ?>

=====

Most of the HTML is hidden away in the include files, which enhances
stylistic conformity. These can be passed parameters for simple
variable content. Anything more complex requires that one execute a
function; any output from this is put directly inline.

Additional tags handle conditional output and macros, but these two
tags are really all you need.

There are certainly lots of templating systems out there. Here's mine:
www.execulink.com/~robin/wasp/readme.html

-----
robin

A rich couple found their ideal pet in a dog that makes e-mail
programs.



More information about the Python-list mailing list