ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
[ANN] HTMLTemplate 1.0.0
by Peter Maas other posts by this author
Jun 2 2004 1:05AM messages near this date
[ANN] HTMLTemplate 1.0.0 | Authentication for socket communication ...
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@[...].de
-------------------------------------------------------------------
Thread:
Has Temp2
Pete Prodoehl
Peter Maas
davidf
esj
Peter Maas

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved