HTML Generators
Chris Gonnerman
chris.gonnerman at newcenturycomputers.net
Sat Feb 9 23:47:13 EST 2002
----- Original Message -----
From: "Mark Sass" <sassman at nucentrix.net>
> Are there any HTML generator modules for Python? I just want to create
> static html and not use scripts i.e. CGI to do it. Any available?
http://newcenturycomputers.net/projects/webpub.html
The script is named makesite.py. I use it for all my static web page
generation, and the latest version also supports being used from a CGI
script. makesite.py is a templating tool; each source (content) document
is stored in a form similar to rfc822; for instance:
Title: Home Page
<h1>Example Page</h1>
<p>
Here is an example content page.
This would be stored as index.src (for instance). Then, the template looks
like this:
Extensions: .src
<html>
<head>
<title>Sample Site -- <!--%title%--></title>
</head>
<body bgcolor=white>
<!--%body%-->
</body>
</html>
The default name for a template file is template.site. When you run
makesite.py in the same folder as template.site and the .src files,
each .src file is merged with the template.site file to create a like-
named html file.
The <!--%somenamehere%--> comments in the template are replaced with the
source file headers which match the name (case-insensitive). The "body"
of the source file is put where the <!--%body%--> name appears. If a
name can't be found in the source file headers, the template file headers
are consulted; there is also a default data context which contains the
name "date" mapping to today's date in MM/DD/YYYY format. (I haven't
needed any other formats so far...) Header values can be substituted
inside header values recursively.
Sounds more complex than it is...
More information about the Python-list
mailing list