[ANN] HTMLTemplate 1.0.0
Peter Maas
peter.maas at mplusr.de
Wed Jun 2 07:58:22 EDT 2004
David Fraser schrieb:
>> Did you find these alternatives unsatisfactory? If somebody wants
>> to use a Python templating framework why should he prefer
>> HTMLTemplate?
[..]
> It looks cool because it doesn't embed Python code in the template.
> Do any of the other frameworks have this approach?
That's your personal taste. If this is what you like about HTMLTemplate
that's fine. I don't bother wether a template language contains Python
code or not. To answer your question:
Hamish's example rewritten in TAL (TAL lines below Hamish's equivalents):
<html>
<head>
<title node="con:title">TITLE</title>
###TAL <title tal:content="here/title">TITLE</title>
</head>
<body>
<ul>
<li node="rep:item">
###TAL <li tal:repeat="link here/objectValues">
<a href="" node="con:link">LINK</a>
###TAL <a tal:attributes="href link/name" tal:content="link/title">LINK</a>
</li>
</ul>
</body>
</html>
But I wanted to read Hamish's thoughts. That would be helpful for
programmers because it takes some time to find your way through the
maze of Python template languages.
I prefer Cheetah. Hamish's example in Cheetah:
<html>
<head>
<title>$title</title>
</head>
<body>
<ul>
#for $link in $links
<li>
<a href="$link.href">$link.text</a>
</li>
#end for
</ul>
</body>
</html>
Advantages:
- No magic
- placeholders occupy the places of their replacements
- logic is visible in the template
-> you see what's going on
- logic is visible in the rendered html page
-> you see where the replacements will go
- Cheetah templates everything, not only markup
Mit freundlichen Gruessen,
Peter Maas
--
-------------------------------------------------------------------
Peter Maas, M+R Infosysteme, D-52070 Aachen, Hubert-Wienen-Str. 24
Tel +49-241-93878-0 Fax +49-241-93878-20 eMail peter.maas at mplusr.de
-------------------------------------------------------------------
More information about the Python-list
mailing list