Custom HTML filter for SSI-like directives

Hi All,

I've programmed a cutom HTML filter to be used with html.HtmlWindow
class. The purpose is to parse various SSI-like directives inside
comment tags. It can be used to create template documents including
other files or performing more complex HTML-generation based on some
conditions. It can also repeat some lines to generate lists and tables.
I find it easier to use than generating HTML programmatically in Python.
I'm using this for a project where a browser-like interface is used.

A quick example:

<html>
  <body>
    <!--#exec cmd="import math" -->
    sqrt(2)=<!--#echo expr="math.sqrt(2)" -->
  </body>
</html>

Will produce "sqrt(2)=1.41421356237" on the output.

Commands currently supported are: include, echo, exec, set,
if/elif/else/endif. Some commands can evaluate Python expressions.

Some info about SSI can be found here:
http://httpd.apache.org/docs/1.3/howto/ssi.html

Template files must be created with a custom extension. The extension
must be registered with the file type system using provided AddFilter
method (it also creates and registers the filter, so must be called
after creating wxApp object). Unfortunately it seems to be impossible to
override existing MIME types. I use "phtml" as the default extension.
Another limitation is that there can be only one filter for all
HtmlWindow objects because the method AddFilter is static.

Attached module can be run to show a simple example. Hope someone will
find it useful.

Best regards,

Roman

phtml.py (13.6 KB)