Python Webpages
Tom Chance
tomchance at gmx.net
Tue Apr 30 10:46:03 EDT 2002
Sorry if I'm coming in at a tangent to this conversation, or repeating
something that's been said before, but I've been using Perl and the
HTML::Template module for ages now and it seems to me to be the natural
way to do things. You basically create a series of HTML templates, and
put fake HTML tags into them like:
<TMPL_VAR NAME=TITLE>
And then in your perl scripts you call a new HTML::Template object, give
it the values to put into all of the fake HTML tags, and tell
HTML::Template to print out the page, like so:
use HTML::Template;
my $template = HTML::Template->new(filename => 'template.html');
$template->param(TITLE => 'Hello there!');
print $template->output();
This lets you keep the HTML seperate from the logic of the script
(something which I find preferable to PHP's system, especially if the
script is vey complicated), which is handy both if you have seperate
people doing the HTML and the Perl code, and if like me you don't want
to be fiddling around with HTML every time you want to edit the logic of
the script. It lends to very neatly laid out HTML and Perl. Perhaps
Python merely needs an equivalent of this?
Tom
More information about the Python-list
mailing list