Python-Powered Templates with Cheetah
Subject:   tip for html templates
Date:   2005-01-14 06:19:13
From:   filz
I use Cheetah a lot. Both as template system for html pages and as codegenerator.

Looking for a way to better work with html page designers I found this tip in the cheetah mailinglist:
the default directive token is '#'.

This can be changed:

t = Template(file=filename, compilerSettings={'directiveStartToken': '<!-- #', 'directiveEndToken': '#-->'})

Calling Template with the optional compilerSettings argument as above tells the template engine to use '<!-- #' and '#-->' to delimit directives

So code like:

<!-- #for $myObj in $objList #-->
<!-- #end for #-->

is valid html and can be viewed correctly from html designers in applications like Dreamweaver.