We've expanded our news coverage and improved our search! Visit
news.oreilly.com for the latest or search for all things across O'Reilly!
Article:
 |
|
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 #-->
<tr>
<td>$myObj.attr1</td><td>$myObj.attr2</td>
</tr>
<!-- #end for #-->
is valid html and can be viewed correctly from html designers in applications like Dreamweaver.
|